Skip to content

Commit 2a1c06a

Browse files
committed
modfile: update toolchain syntax
Final revisions for Go 1.21: lock down the toolchain syntax to use 'toolchain default' instead of 'toolchain local', to avoid confusion with 'GOTOOLCHAIN=local'; 'toolchain local' does not always mean the same thing. Also remove the prefix-go1.2.3 toolchain name form, leaving only go1.2.3-suffix. There is no need to have two different forms, and it's confusing. For golang/go#57001. Change-Id: I16623c796c620e98178deed899e28a00e85fcc21 Reviewed-on: https://go-review.googlesource.com/c/mod/+/500755 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent e81ad10 commit 2a1c06a

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

modfile/read_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@ func TestParseVersions(t *testing.T) {
459459
{desc: "tool", input: "module m\ntoolchain go1.2\n", ok: true},
460460
{desc: "tool1", input: "module m\ntoolchain go1.2.3\n", ok: true},
461461
{desc: "tool2", input: "module m\ntoolchain go1.2rc1\n", ok: true},
462-
{desc: "tool3", input: "module m\ntoolchain gccgo-go1.2rc1\n", ok: true},
463-
{desc: "tool4", input: "module m\ntoolchain local\n", ok: true},
462+
{desc: "tool3", input: "module m\ntoolchain go1.2rc1-gccgo\n", ok: true},
463+
{desc: "tool4", input: "module m\ntoolchain default\n", ok: true},
464464
{desc: "tool5", input: "module m\ntoolchain inconceivable!\n", ok: false, laxOK: true},
465465
}
466466
t.Run("Strict", func(t *testing.T) {

modfile/rule.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (parse
306306
var GoVersionRE = lazyregexp.New(`^([1-9][0-9]*)\.(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?([a-z]+[0-9]+)?$`)
307307
var laxGoVersionRE = lazyregexp.New(`^v?(([1-9][0-9]*)\.(0|[1-9][0-9]*))([^0-9].*)$`)
308308

309-
// Toolchains must be named beginning with `go1` or containing `-go1` as a substring,
310-
// like "go1.20.3" or "gccgo-go1.20.3". As a special case, "local" is also permitted.
311-
var ToolchainRE = lazyregexp.New(`^local$|(^|-)go1`)
309+
// Toolchains must be named beginning with `go1`,
310+
// like "go1.20.3" or "go1.20.3-gccgo". As a special case, "default" is also permitted.
311+
var ToolchainRE = lazyregexp.New(`^default$|^go1($|\.)`)
312312

313313
func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, args []string, fix VersionFixer, strict bool) {
314314
// If strict is false, this module is a dependency.

modfile/testdata/goline.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
go 1.2.3
22

3-
toolchain local
3+
toolchain default

modfile/testdata/goline.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
go 1.2.3
2-
toolchain local
2+
toolchain default

modfile/testdata/work/goline.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
go 1.2.3
22

3-
toolchain local
3+
toolchain default

modfile/testdata/work/goline.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
go 1.2.3
2-
toolchain local
2+
toolchain default

0 commit comments

Comments
 (0)