This commit is contained in:
Jason 2018-09-28 20:43:23 +00:00 committed by GitHub
commit 67f9e93097
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,6 +55,7 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime" "runtime"
"strconv"
"strings" "strings"
"time" "time"
@ -203,6 +204,36 @@ func main() {
} }
} }
//To make sure more and more Go version is suitable for ETH,
//so I change the way of Checking Go version.
//If the value is 'true' then current Go version is available to Go-ethereum.
func checkGoVersion(minVersion string) bool {
if minVersion == "" || !strings.Contains(minVersion, "go") {
return false
}
var isEqual bool = true
minVerArr := strings.Split(strings.TrimLeft(minVersion, "go"), ".")
currVerArr := strings.Split(strings.TrimLeft(runtime.Version(), "go"), ".")
shorterArrLen := len(minVerArr)
if shorterArrLen > len(currVerArr) {
shorterArrLen = len(currVerArr)
}
for i := 0; i < shorterArrLen; i++ {
minVerInt, _ := strconv.Atoi(strings.TrimLeft(minVerArr[i], "0"))
currVerInt, _ := strconv.Atoi(strings.TrimLeft(currVerArr[i], "0"))
if minVerInt > currVerInt {
return false
}
if isEqual && minVerInt != currVerInt {
isEqual = false
}
}
if isEqual && shorterArrLen == len(currVerArr) {
return false
}
return true
}
// Compiling // Compiling
func doInstall(cmdline []string) { func doInstall(cmdline []string) {
@ -217,10 +248,7 @@ func doInstall(cmdline []string) {
// failure with outdated Go. This should save them the trouble. // failure with outdated Go. This should save them the trouble.
if !strings.Contains(runtime.Version(), "devel") { if !strings.Contains(runtime.Version(), "devel") {
// Figure out the minor version number since we can't textually compare (1.10 < 1.9) // Figure out the minor version number since we can't textually compare (1.10 < 1.9)
var minor int if !checkGoVersion("go1.9") {
fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)
if minor < 9 {
log.Println("You have Go version", runtime.Version()) log.Println("You have Go version", runtime.Version())
log.Println("go-ethereum requires at least Go version 1.9 and cannot") log.Println("go-ethereum requires at least Go version 1.9 and cannot")
log.Println("be compiled with an earlier version. Please upgrade your Go installation.") log.Println("be compiled with an earlier version. Please upgrade your Go installation.")