diff options
author | Ayke van Laethem <[email protected]> | 2021-08-14 15:32:28 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-08-30 09:18:58 +0200 |
commit | ad73986070f4dfc30887cbf9b01f86d7eb914597 (patch) | |
tree | f61d4e5365660121891abc81e630ca1523942da5 | |
parent | 931f87f96a36565cf01291e9a306a808884e5b97 (diff) | |
download | tinygo-ad73986070f4dfc30887cbf9b01f86d7eb914597.tar.gz tinygo-ad73986070f4dfc30887cbf9b01f86d7eb914597.zip |
goenv: improve Go version detection
First look at the VERSION file, only then look at
src/runtime/internal/sys/zversion.go. This makes it possible to
correctly detect the Go version for release candidates.
-rw-r--r-- | goenv/version.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/goenv/version.go b/goenv/version.go index e0fe0949c..87752a015 100644 --- a/goenv/version.go +++ b/goenv/version.go @@ -48,7 +48,10 @@ func GetGorootVersion(goroot string) (major, minor int, err error) { // toolchain for the given GOROOT path. It is usually of the form `go1.x.y` but // can have some variations (for beta releases, for example). func GorootVersionString(goroot string) (string, error) { - if data, err := ioutil.ReadFile(filepath.Join( + if data, err := ioutil.ReadFile(filepath.Join(goroot, "VERSION")); err == nil { + return string(data), nil + + } else if data, err := ioutil.ReadFile(filepath.Join( goroot, "src", "runtime", "internal", "sys", "zversion.go")); err == nil { r := regexp.MustCompile("const TheVersion = `(.*)`") @@ -59,9 +62,6 @@ func GorootVersionString(goroot string) (string, error) { return string(matches[1]), nil - } else if data, err := ioutil.ReadFile(filepath.Join(goroot, "VERSION")); err == nil { - return string(data), nil - } else { return "", err } |