mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 07:23:39 +00:00
all: refactor goenv.Version to add the git sha1 if needed
Previously all (except one!) usage of goenv.Version manually added the git sha1 hash, leading to duplicate code. I've moved this to do it all in one place, to avoid this duplication.
This commit is contained in:
committed by
Ron Evans
parent
2320b18953
commit
5cd8ba2421
+11
-1
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Version of TinyGo.
|
||||
// Update this value before release of new version of software.
|
||||
const Version = "0.30.0"
|
||||
const version = "0.30.0"
|
||||
|
||||
var (
|
||||
// This variable is set at build time using -ldflags parameters.
|
||||
@@ -17,6 +17,16 @@ var (
|
||||
GitSha1 string
|
||||
)
|
||||
|
||||
// Return TinyGo version, either in the form 0.30.0 or as a development version
|
||||
// (like 0.30.0-dev-abcd012).
|
||||
func Version() string {
|
||||
v := version
|
||||
if strings.HasSuffix(version, "-dev") && GitSha1 != "" {
|
||||
v += "-" + GitSha1
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// GetGorootVersion returns the major and minor version for a given GOROOT path.
|
||||
// If the goroot cannot be determined, (0, 0) is returned.
|
||||
func GetGorootVersion() (major, minor int, err error) {
|
||||
|
||||
Reference in New Issue
Block a user