Use Go 1.11 modules with Mage

See #5115
This commit is contained in:
Bjørn Erik Pedersen
2018-08-25 17:58:04 +02:00
parent fce32c07fb
commit 45c9c45d1d
4 changed files with 61 additions and 23 deletions

View File

@@ -32,14 +32,26 @@ func init() {
if exe := os.Getenv("GOEXE"); exe != "" {
goexe = exe
}
// We want to use Go 1.11 modules even if the source lives inside GOPATH.
// The default is "auto".
os.Setenv("GO111MODULE", "on")
}
func getDep() error {
if !isWindows() {
// We only need this on Appveyor.
// TODO(bep) go11 clean up the vendor stuff once Appveyor gets Go 1.11.
return nil
}
return sh.Run(goexe, "get", "-u", "github.com/golang/dep/cmd/dep")
}
// Install Go Dep and sync Hugo's vendored dependencies
func Vendor() error {
if !isWindows() {
return nil
}
mg.Deps(getDep)
return sh.Run("dep", "ensure")
}
@@ -268,6 +280,10 @@ func isGoLatest() bool {
return strings.Contains(runtime.Version(), "1.11")
}
func isWindows() bool {
return runtime.GOOS == "windows"
}
func buildTags() string {
// To build the extended Hugo SCSS/SASS enabled version, build with
// HUGO_BUILD_TAGS=extended mage install etc.