]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[release-branch.go1.22] cmd/compile: accept -lang=go1 as -lang=go1.0
authorMatthew Dempsky <mdempsky@google.com>
Thu, 8 Feb 2024 01:25:48 +0000 (17:25 -0800)
committerThan McIntosh <thanm@google.com>
Fri, 16 Feb 2024 15:53:59 +0000 (15:53 +0000)
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

src/cmd/compile/internal/types/goversion.go
src/cmd/go/testdata/script/build_issue_65528.txt [new file with mode: 0644]

index c57493a5cb2a6ed2640a6efd86ada4d2d82fe17a..ac08a49d0cab7c928fd2761394eba89f08912b9e 100644 (file)
@@ -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 (file)
index 0000000..ab4d62b
--- /dev/null
@@ -0,0 +1,9 @@
+go build
+
+-- go.mod --
+module test
+
+go 1.0
+
+-- p.go --
+package p