mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/dist, runtime: make runtime version available as runtime.buildVersion
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>
This commit is contained in:
parent
68c6aad58b
commit
86f1944e86
2 changed files with 6 additions and 6 deletions
6
src/cmd/dist/buildruntime.go
vendored
6
src/cmd/dist/buildruntime.go
vendored
|
|
@ -16,12 +16,11 @@ import (
|
||||||
|
|
||||||
// mkzversion writes zversion.go:
|
// mkzversion writes zversion.go:
|
||||||
//
|
//
|
||||||
// package runtime
|
// package sys
|
||||||
// const DefaultGoroot = <goroot>
|
// const DefaultGoroot = <goroot>
|
||||||
// const TheVersion = <version>
|
// const TheVersion = <version>
|
||||||
// const Goexperiment = <goexperiment>
|
// const Goexperiment = <goexperiment>
|
||||||
// const StackGuardMultiplier = <multiplier value>
|
// const StackGuardMultiplier = <multiplier value>
|
||||||
// const BuildVersion = <build version>
|
|
||||||
//
|
//
|
||||||
func mkzversion(dir, file string) {
|
func mkzversion(dir, file string) {
|
||||||
out := fmt.Sprintf(
|
out := fmt.Sprintf(
|
||||||
|
|
@ -32,8 +31,7 @@ func mkzversion(dir, file string) {
|
||||||
"const DefaultGoroot = `%s`\n"+
|
"const DefaultGoroot = `%s`\n"+
|
||||||
"const TheVersion = `%s`\n"+
|
"const TheVersion = `%s`\n"+
|
||||||
"const Goexperiment = `%s`\n"+
|
"const Goexperiment = `%s`\n"+
|
||||||
"const StackGuardMultiplier = %d\n\n"+
|
"const StackGuardMultiplier = %d\n\n", goroot_final, findgoversion(), os.Getenv("GOEXPERIMENT"), stackGuardMultiplier())
|
||||||
"var BuildVersion = TheVersion\n", goroot_final, findgoversion(), os.Getenv("GOEXPERIMENT"), stackGuardMultiplier())
|
|
||||||
|
|
||||||
writefile(out, file, writeSkipSame)
|
writefile(out, file, writeSkipSame)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var buildVersion = sys.TheVersion
|
||||||
|
|
||||||
// Goroutine scheduler
|
// Goroutine scheduler
|
||||||
// The scheduler's job is to distribute ready-to-run goroutines over worker threads.
|
// 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")
|
throw("unknown runnable goroutine during bootstrap")
|
||||||
}
|
}
|
||||||
|
|
||||||
if sys.BuildVersion == "" {
|
if buildVersion == "" {
|
||||||
// Condition should never trigger. This code just serves
|
// Condition should never trigger. This code just serves
|
||||||
// to ensure runtime·buildVersion is kept in the resulting binary.
|
// to ensure runtime·buildVersion is kept in the resulting binary.
|
||||||
sys.BuildVersion = "unknown"
|
buildVersion = "unknown"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue