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 /main.go | |
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 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -1212,15 +1212,10 @@ func getBMPPorts() (gdbPort, uartPort string, err error) { } func usage(command string) { - version := goenv.Version - if strings.HasSuffix(version, "-dev") && goenv.GitSha1 != "" { - version += "-" + goenv.GitSha1 - } - switch command { default: fmt.Fprintln(os.Stderr, "TinyGo is a Go compiler for small places.") - fmt.Fprintln(os.Stderr, "version:", version) + fmt.Fprintln(os.Stderr, "version:", goenv.Version()) fmt.Fprintf(os.Stderr, "usage: %s <command> [arguments]\n", os.Args[0]) fmt.Fprintln(os.Stderr, "\ncommands:") fmt.Fprintln(os.Stderr, " build: compile packages and dependencies") @@ -1874,11 +1869,7 @@ func main() { if s, err := goenv.GorootVersionString(); err == nil { goversion = s } - version := goenv.Version - if strings.HasSuffix(goenv.Version, "-dev") && goenv.GitSha1 != "" { - version += "-" + goenv.GitSha1 - } - fmt.Printf("tinygo version %s %s/%s (using go version %s and LLVM version %s)\n", version, runtime.GOOS, runtime.GOARCH, goversion, llvm.Version) + fmt.Printf("tinygo version %s %s/%s (using go version %s and LLVM version %s)\n", goenv.Version(), runtime.GOOS, runtime.GOARCH, goversion, llvm.Version) case "env": if flag.NArg() == 0 { // Show all environment variables. |