-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add syntax support for toolchain directive
This directive was added to `go.mod` with Go 1.21[1] So that this directive can be highlighted in `go.mod`. It's not entirely clear exactly what the fully supported syntax is. The docs[1] suggests any Go release version, e.g. * `go1.20` * `go1.21.1` * `go1.21.1rc1` `golang.org/x/mod` gives a much more relaxed definition, requiring just that things match against the regex `^default$|^go1($|\.)`[2] Finally there's `FromToolchain` from the stdlib's internals for processing versions[3] which is broader than that from[1] but more limited than that from[2], supporting arbitrary suffixes (after any of `" \t-"`) appended to the version, e.g. * go1.21.3-somesuffix * go1.21rc2-somesuffix * go1.21 some-suffix The approach taken for the syntax matching here is closest to this final condition, and will not include some toolchain verison's that would be supported by the `modfile` regex, e.g. * go1.21.1blah * go1.21!some-suffix Since these would be rejected by the `go` tool itself with an error like > go: invalid toolchain "go1.21.1blah" in go.mod
- Loading branch information
1 parent
5bed70d
commit 26f4ff5
Showing
2 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters