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:
Ayke van Laethem
2023-09-28 15:42:50 +02:00
committed by Ron Evans
parent 2320b18953
commit 5cd8ba2421
5 changed files with 17 additions and 21 deletions
+11 -1
View File
@@ -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) {