forked from TrueCloudLab/restic
build: Correct checks for minimum Go version
This commit is contained in:
parent
92df039e5d
commit
333c2c6ed4
1 changed files with 4 additions and 8 deletions
12
build.go
12
build.go
|
@ -3,8 +3,8 @@
|
||||||
// This program aims to make building Go programs for end users easier by just
|
// This program aims to make building Go programs for end users easier by just
|
||||||
// calling it with `go run`, without having to setup a GOPATH.
|
// calling it with `go run`, without having to setup a GOPATH.
|
||||||
//
|
//
|
||||||
// This program needs Go >= 1.12. It'll use Go modules for compilation. It
|
// This program checks for a minimum Go version. It will use Go modules for
|
||||||
// builds the package configured as Main in the Config struct.
|
// compilation. It builds the package configured as Main in the Config struct.
|
||||||
|
|
||||||
// BSD 2-Clause License
|
// BSD 2-Clause License
|
||||||
//
|
//
|
||||||
|
@ -59,7 +59,7 @@ var config = Config{
|
||||||
Main: "./cmd/restic", // package name for the main package
|
Main: "./cmd/restic", // package name for the main package
|
||||||
DefaultBuildTags: []string{"selfupdate"}, // specify build tags which are always used
|
DefaultBuildTags: []string{"selfupdate"}, // specify build tags which are always used
|
||||||
Tests: []string{"./..."}, // tests to run
|
Tests: []string{"./..."}, // tests to run
|
||||||
MinVersion: GoVersion{Major: 1, Minor: 14, Patch: 0}, // minimum Go version supported
|
MinVersion: GoVersion{Major: 1, Minor: 15, Patch: 0}, // minimum Go version supported
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config configures the build.
|
// Config configures the build.
|
||||||
|
@ -319,12 +319,8 @@ func (v GoVersion) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if !goVersion.AtLeast(GoVersion{1, 12, 0}) {
|
|
||||||
die("Go version (%v) is too old, restic requires Go >= 1.12\n", goVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !goVersion.AtLeast(config.MinVersion) {
|
if !goVersion.AtLeast(config.MinVersion) {
|
||||||
fmt.Fprintf(os.Stderr, "%s detected, this program requires at least %s\n", goVersion, config.MinVersion)
|
fmt.Fprintf(os.Stderr, "Detected version %s is too old, restic requires at least %s\n", goVersion, config.MinVersion)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue