Specifically if there are experiments but no nonstandard toolchain
suffix such as "-devel", the go version will not be valid according to
go/version.IsValid. To fix that, always put the X: part into the suffix,
resulting in, for example, go1.25.0-X:foo.
Fixes #75953
Change-Id: I6a6a696468f3ba9b82b6a410fb88831428e93b58
Reviewed-on: https://go-review.googlesource.com/c/go/+/719701
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
if i := strings.Index(version, " X:"); i >= 0 {
return version[:i]
}
+ if i := strings.Index(version, "-X:"); i >= 0 {
+ return version[:i]
+ }
return version
}
buildVersion := buildcfg.Version
if goexperiment := buildcfg.Experiment.String(); goexperiment != "" {
- buildVersion += " X:" + goexperiment
+ sep := " "
+ if !strings.Contains(buildVersion, "-") { // See go.dev/issue/75953.
+ sep = "-"
+ }
+ buildVersion += sep + "X:" + goexperiment
}
addstrdata1(ctxt, "runtime.buildVersion="+buildVersion)