Skip to content

Commit

Permalink
cmd/compile: accept -lang=go1 as -lang=go1.0
Browse files Browse the repository at this point in the history
Fixes #65528.

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>
  • Loading branch information
mdempsky committed Feb 8, 2024
1 parent 58fea5d commit 08370dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cmd/compile/internal/types/goversion.go
Expand Up @@ -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
Expand All @@ -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"`)
Expand Down
9 changes: 9 additions & 0 deletions 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

0 comments on commit 08370dc

Please sign in to comment.