From fb86598cd31ce6010aea91122bbe277b9e03b52d Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 7 Feb 2024 17:25:48 -0800 Subject: [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 Reviewed-by: Bryan Mills (cherry picked from commit 08370dcd9af8122956fc3ab024889c5357fffd5a) Reviewed-on: https://go-review.googlesource.com/c/go/+/562815 --- src/cmd/compile/internal/types/goversion.go | 6 +++++- src/cmd/go/testdata/script/build_issue_65528.txt | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/cmd/go/testdata/script/build_issue_65528.txt 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 -- cgit v1.2.3-54-g00ecf