]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: move "devel" substring in git-inferred development version
authorDmitri Shuralyov <dmitshur@golang.org>
Fri, 25 Apr 2025 00:48:10 +0000 (20:48 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 30 Apr 2025 19:54:52 +0000 (12:54 -0700)
Keep the property that the "devel" substring is always present in these
development versions of Go, but also gain the property that it's viable
to use functions in the go/version package such as Lang, Compare, and
get the expected results without needing to trim the "devel " prefix.

For #73369.
For #41116.
Fixes #73372.

Change-Id: Ieea4692e8c6cf0135e010f49f85300f6b038d6b1
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/668015
Reviewed-by: Funda Secgin <fundasecgin30@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/dist/build.go

index aa82c851bbe694928f6c27e2ec84378c14f6dbef..aa106e45c51834ac98eab3ac087edb2fe75b28f8 100644 (file)
@@ -426,6 +426,10 @@ func findgoversion() string {
        // Otherwise, use Git.
        //
        // Include 1.x base version, hash, and date in the version.
+       // Make sure it includes the substring "devel", but otherwise
+       // use a format compatible with https://go.dev/doc/toolchain#name
+       // so that it's possible to use go/version.Lang, Compare and so on.
+       // See go.dev/issue/73372.
        //
        // Note that we lightly parse internal/goversion/goversion.go to
        // obtain the base version. We can't just import the package,
@@ -437,7 +441,7 @@ func findgoversion() string {
        if m == nil {
                fatalf("internal/goversion/goversion.go does not contain 'const Version = ...'")
        }
-       version := fmt.Sprintf("devel go1.%s-", m[1])
+       version := fmt.Sprintf("go1.%s-devel_", m[1])
        version += chomp(run(goroot, CheckExit, "git", "log", "-n", "1", "--format=format:%h %cd", "HEAD"))
 
        // Cache version.