From 4d2a48d817afa7a0f7301046e33fee74bb188212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 2 Jan 2018 12:28:07 +0200 Subject: [PATCH 1/2] build: fix version comparison for go1.10 and beyond (#15781) --- build/ci.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/build/ci.go b/build/ci.go index 6fe03db71..dc0f5ce2d 100644 --- a/build/ci.go +++ b/build/ci.go @@ -176,11 +176,17 @@ func doInstall(cmdline []string) { // Check Go version. People regularly open issues about compilation // failure with outdated Go. This should save them the trouble. - if runtime.Version() < "go1.7" && !strings.Contains(runtime.Version(), "devel") { - log.Println("You have Go version", runtime.Version()) - log.Println("go-ethereum requires at least Go version 1.7 and cannot") - log.Println("be compiled with an earlier version. Please upgrade your Go installation.") - os.Exit(1) + if !strings.Contains(runtime.Version(), "devel") { + // Figure out the minor version number since we can't textually compare (1.10 < 1.7) + var minor int + fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor) + + if minor < 7 { + log.Println("You have Go version", runtime.Version()) + log.Println("go-ethereum requires at least Go version 1.7 and cannot") + log.Println("be compiled with an earlier version. Please upgrade your Go installation.") + os.Exit(1) + } } // Compile packages given as arguments, or everything if there are no arguments. packages := []string{"./..."} @@ -254,7 +260,10 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd { if subcmd == "build" || subcmd == "install" || subcmd == "test" { // Go CGO has a Windows linker error prior to 1.8 (https://github.com/golang/go/issues/8756). // Work around issue by allowing multiple definitions for <1.8 builds. - if runtime.GOOS == "windows" && runtime.Version() < "go1.8" { + var minor int + fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor) + + if runtime.GOOS == "windows" && minor < 8 { cmd.Args = append(cmd.Args, []string{"-ldflags", "-extldflags -Wl,--allow-multiple-definition"}...) } } From 31ffdb3b0e0b97b85180f8632fc7dbbf24de3d33 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Thu, 1 Mar 2018 09:51:46 +0100 Subject: [PATCH 2/2] Fix building with Go 1.10 --- cmd/geth/usage.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 04c350c6c..85d6c5702 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -22,8 +22,6 @@ import ( "io" "sort" - "strings" - "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/internal/debug" "gopkg.in/urfave/cli.v1"