aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2024-02-07 17:25:48 -0800
committerThan McIntosh <thanm@google.com>2024-02-16 15:53:59 +0000
commitfb86598cd31ce6010aea91122bbe277b9e03b52d (patch)
treed4d6dbeeb5ba9bfeac4c68057586fae8a56b0120
parent6fbd01a71108b185479457fd9393b78bcd3dde55 (diff)
downloadgo-fb86598cd31ce6010aea91122bbe277b9e03b52d.tar.gz
go-fb86598cd31ce6010aea91122bbe277b9e03b52d.zip
[release-branch.go1.22] cmd/compile: accept -lang=go1 as -lang=go1.0
Fixes #65619. Change-Id: I55fef8cf7be4654c7242462d45f12999e0c91c02 Reviewed-on: https://go-review.googlesource.com/c/go/+/562322 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com> (cherry picked from commit 08370dcd9af8122956fc3ab024889c5357fffd5a) Reviewed-on: https://go-review.googlesource.com/c/go/+/562815
-rw-r--r--src/cmd/compile/internal/types/goversion.go6
-rw-r--r--src/cmd/go/testdata/script/build_issue_65528.txt9
2 files changed, 14 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types/goversion.go b/src/cmd/compile/internal/types/goversion.go
index c57493a5cb..ac08a49d0c 100644
--- a/src/cmd/compile/internal/types/goversion.go
+++ b/src/cmd/compile/internal/types/goversion.go
@@ -34,7 +34,7 @@ func AllowsGoVersion(major, minor int) bool {
}
// ParseLangFlag verifies that the -lang flag holds a valid value, and
-// exits if not. It initializes data used by langSupported.
+// exits if not. It initializes data used by AllowsGoVersion.
func ParseLangFlag() {
if base.Flag.Lang == "" {
return
@@ -59,6 +59,10 @@ func ParseLangFlag() {
// parseLang parses a -lang option into a langVer.
func parseLang(s string) (lang, error) {
+ if s == "go1" { // cmd/go's new spelling of "go1.0" (#65528)
+ s = "go1.0"
+ }
+
matches := goVersionRE.FindStringSubmatch(s)
if matches == nil {
return lang{}, fmt.Errorf(`should be something like "go1.12"`)
diff --git a/src/cmd/go/testdata/script/build_issue_65528.txt b/src/cmd/go/testdata/script/build_issue_65528.txt
new file mode 100644
index 0000000000..ab4d62bbb2
--- /dev/null
+++ b/src/cmd/go/testdata/script/build_issue_65528.txt
@@ -0,0 +1,9 @@
+go build
+
+-- go.mod --
+module test
+
+go 1.0
+
+-- p.go --
+package p