mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-20 20:39:06 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
931f87f96a
commit
ad73986070
+4
-4
@@ -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
|
// 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).
|
// can have some variations (for beta releases, for example).
|
||||||
func GorootVersionString(goroot string) (string, error) {
|
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 {
|
goroot, "src", "runtime", "internal", "sys", "zversion.go")); err == nil {
|
||||||
|
|
||||||
r := regexp.MustCompile("const TheVersion = `(.*)`")
|
r := regexp.MustCompile("const TheVersion = `(.*)`")
|
||||||
@@ -59,9 +62,6 @@ func GorootVersionString(goroot string) (string, error) {
|
|||||||
|
|
||||||
return string(matches[1]), nil
|
return string(matches[1]), nil
|
||||||
|
|
||||||
} else if data, err := ioutil.ReadFile(filepath.Join(goroot, "VERSION")); err == nil {
|
|
||||||
return string(data), nil
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user