diff options
author | Ayke van Laethem <[email protected]> | 2023-09-28 15:42:50 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-10-04 16:20:32 +0200 |
commit | 5cd8ba242157d552d3104ce09d06c5418c52eab4 (patch) | |
tree | 8015fe84aa58fe4b7a8ddcb1e093491502b60ccf /goenv | |
parent | 2320b18953e925fc6c79347f3fcc94b5b9f77885 (diff) | |
download | tinygo-5cd8ba242157d552d3104ce09d06c5418c52eab4.tar.gz tinygo-5cd8ba242157d552d3104ce09d06c5418c52eab4.zip |
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.
Diffstat (limited to 'goenv')
-rw-r--r-- | goenv/version.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/goenv/version.go b/goenv/version.go index f89b43f1a..fb16d5a4b 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -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) { |