]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist, runtime: make runtime version available as runtime.buildVersion
authorShenghou Ma <minux@golang.org>
Sun, 6 Dec 2015 22:35:12 +0000 (17:35 -0500)
committerMinux Ma <minux@golang.org>
Wed, 16 Dec 2015 05:42:40 +0000 (05:42 +0000)
So that there is a uniformed way to retrieve Go version from a Go
binary, starting from Go 1.4 (see https://golang.org/cl/117040043)

Updates #13507.

Change-Id: Iaa2b14fca2d8c4d883d3824e2efc82b3e6fe2624
Reviewed-on: https://go-review.googlesource.com/17459
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/dist/buildruntime.go
src/runtime/proc.go

index c1a9b817f88a01267e4ea5891ade7215c033d59d..6e802219babc5e5cdf40f6358519b3ee0b6e18fe 100644 (file)
@@ -16,12 +16,11 @@ import (
 
 // mkzversion writes zversion.go:
 //
-//     package runtime
+//     package sys
 //     const DefaultGoroot = <goroot>
 //     const TheVersion = <version>
 //     const Goexperiment = <goexperiment>
 //     const StackGuardMultiplier = <multiplier value>
-//     const BuildVersion = <build version>
 //
 func mkzversion(dir, file string) {
        out := fmt.Sprintf(
@@ -32,8 +31,7 @@ func mkzversion(dir, file string) {
                        "const DefaultGoroot = `%s`\n"+
                        "const TheVersion = `%s`\n"+
                        "const Goexperiment = `%s`\n"+
-                       "const StackGuardMultiplier = %d\n\n"+
-                       "var BuildVersion = TheVersion\n", goroot_final, findgoversion(), os.Getenv("GOEXPERIMENT"), stackGuardMultiplier())
+                       "const StackGuardMultiplier = %d\n\n", goroot_final, findgoversion(), os.Getenv("GOEXPERIMENT"), stackGuardMultiplier())
 
        writefile(out, file, writeSkipSame)
 }
index d75af10206e7da2ce01f2a9ce1354e863e065513..04e4c7c548194c4e5335dbabb8c45b31575ac36c 100644 (file)
@@ -10,6 +10,8 @@ import (
        "unsafe"
 )
 
+var buildVersion = sys.TheVersion
+
 // Goroutine scheduler
 // The scheduler's job is to distribute ready-to-run goroutines over worker threads.
 //
@@ -445,10 +447,10 @@ func schedinit() {
                throw("unknown runnable goroutine during bootstrap")
        }
 
-       if sys.BuildVersion == "" {
+       if buildVersion == "" {
                // Condition should never trigger.  This code just serves
                // to ensure runtimeĀ·buildVersion is kept in the resulting binary.
-               sys.BuildVersion = "unknown"
+               buildVersion = "unknown"
        }
 }