Skip to content

Commit 766dc5d

Browse files
committed
modfile: use new go version string format in WorkFile.add error
For golang/go#61888 Tested: Ran go test ./modfile Change-Id: I254fe559f25ac643e842a935954d18744ae87b0b Reviewed-on: https://go-review.googlesource.com/c/mod/+/560875 Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Sam Thanawalla <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent fa1ba42 commit 766dc5d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modfile/rule.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ var laxGoVersionRE = lazyregexp.New(`^v?(([1-9][0-9]*)\.(0|[1-9][0-9]*))([^0-9].
308308

309309
// Toolchains must be named beginning with `go1`,
310310
// like "go1.20.3" or "go1.20.3-gccgo". As a special case, "default" is also permitted.
311+
// TODO(samthanawalla): Replace regex with https://pkg.go.dev/go/version#IsValid in 1.23+
311312
var ToolchainRE = lazyregexp.New(`^default$|^go1($|\.)`)
312313

313314
func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, args []string, fix VersionFixer, strict bool) {
@@ -384,7 +385,7 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a
384385
errorf("toolchain directive expects exactly one argument")
385386
return
386387
} else if strict && !ToolchainRE.MatchString(args[0]) {
387-
errorf("invalid toolchain version '%s': must match format go1.23.0 or local", args[0])
388+
errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0])
388389
return
389390
}
390391
f.Toolchain = &Toolchain{Syntax: line}
@@ -630,7 +631,7 @@ func (f *WorkFile) add(errs *ErrorList, line *Line, verb string, args []string,
630631
errorf("go directive expects exactly one argument")
631632
return
632633
} else if !GoVersionRE.MatchString(args[0]) {
633-
errorf("invalid go version '%s': must match format 1.23", args[0])
634+
errorf("invalid go version '%s': must match format 1.23.0", args[0])
634635
return
635636
}
636637

@@ -646,7 +647,7 @@ func (f *WorkFile) add(errs *ErrorList, line *Line, verb string, args []string,
646647
errorf("toolchain directive expects exactly one argument")
647648
return
648649
} else if !ToolchainRE.MatchString(args[0]) {
649-
errorf("invalid toolchain version '%s': must match format go1.23 or local", args[0])
650+
errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0])
650651
return
651652
}
652653

0 commit comments

Comments
 (0)