ref: e627449c0a2f1d2ffac29357c4f1832fc5462870
parent: c2235c6a62d29e0a9e2e274eb340358a445b695d
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Fri Aug 14 08:03:22 EDT 2020
Update to Go 1.15 Fixes #7554
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,6 +1,6 @@
defaults: &defaults
docker:
- - image: bepsays/ci-goreleaser:1.14.3
+ - image: bepsays/ci-goreleaser:1.15.0
environment:
CGO_ENABLED: "0"
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,8 +12,8 @@
git:
depth: false
go:
- - "1.13.11"
- - "1.14.3"
+ - "1.14.7"
+ - "1.15"
- master
arch:
--- a/goreleaser.yml
+++ b/goreleaser.yml
@@ -12,6 +12,9 @@
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
env:
- CGO_ENABLED=0
+ flags:
+ - -buildmode
+ - exe
goos:
- darwin
- linux
@@ -39,6 +42,8 @@
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
flags:
+ - -buildmode
+ - exe
- -tags
- extended
goos:
@@ -53,6 +58,8 @@
- CC=o64-clang
- CXX=o64-clang++
flags:
+ - -buildmode
+ - exe
- -tags
- extended
goos:
@@ -65,6 +72,8 @@
env:
- CGO_ENABLED=1
flags:
+ - -buildmode
+ - exe
- -tags
- extended
goos:
--- a/magefile.go
+++ b/magefile.go
@@ -42,19 +42,25 @@
os.Setenv("GO111MODULE", "on")
}
+func runWith(env map[string]string, cmd string, inArgs ...interface{}) error {
+ s := argsToStrings(inArgs...)
+ return sh.RunWith(env, cmd, s...)
+
+}
+
// Build hugo binary
func Hugo() error {
- return sh.RunWith(flagEnv(), goexe, "build", "-ldflags", ldflags, "-tags", buildTags(), packageName)
+ return runWith(flagEnv(), goexe, "build", "-ldflags", ldflags, buildFlags(), "-tags", buildTags(), packageName)
}
// Build hugo binary with race detector enabled
func HugoRace() error {
- return sh.RunWith(flagEnv(), goexe, "build", "-race", "-ldflags", ldflags, "-tags", buildTags(), packageName)
+ return runWith(flagEnv(), goexe, "build", "-race", "-ldflags", ldflags, buildFlags(), "-tags", buildTags(), packageName)
}
// Install hugo binary
func Install() error {
- return sh.RunWith(flagEnv(), goexe, "install", "-ldflags", ldflags, "-tags", buildTags(), packageName)
+ return runWith(flagEnv(), goexe, "install", "-ldflags", ldflags, buildFlags(), "-tags", buildTags(), packageName)
}
// Uninstall hugo binary
@@ -79,7 +85,7 @@
}
for _, pkg := range generatorPackages {
- if err := sh.RunWith(flagEnv(), goexe, "generate", path.Join(packageName, pkg)); err != nil {
+ if err := runWith(flagEnv(), goexe, "generate", path.Join(packageName, pkg)); err != nil {
return err
}
}
@@ -176,13 +182,13 @@
// Run tests
func Test() error {
env := map[string]string{"GOFLAGS": testGoFlags()}
- return runCmd(env, goexe, "test", "./...", "-tags", buildTags())
+ return runCmd(env, goexe, "test", "./...", buildFlags(), "-tags", buildTags())
}
// Run tests with race detector
func TestRace() error {
env := map[string]string{"GOFLAGS": testGoFlags()}
- return runCmd(env, goexe, "test", "-race", "./...", "-tags", buildTags())
+ return runCmd(env, goexe, "test", "-race", "./...", buildFlags(), "-tags", buildTags())
}
// Run gofmt linter
@@ -318,11 +324,11 @@
return sh.Run(goexe, "tool", "cover", "-html="+coverAll)
}
-func runCmd(env map[string]string, cmd string, args ...string) error {
+func runCmd(env map[string]string, cmd string, args ...interface{}) error {
if mg.Verbose() {
- return sh.RunWith(env, cmd, args...)
+ return runWith(env, cmd, args...)
}
- output, err := sh.OutputWith(env, cmd, args...)
+ output, err := sh.OutputWith(env, cmd, argsToStrings(args...)...)
if err != nil {
fmt.Fprint(os.Stderr, output)
}
@@ -338,6 +344,13 @@
return os.Getenv("CI") != ""
}
+func buildFlags() []string {
+ if runtime.GOOS == "windows" {
+ return []string{"-buildmode", "exe"}
+ }
+ return nil
+}
+
func buildTags() string {
// To build the extended Hugo SCSS/SASS enabled version, build with
// HUGO_BUILD_TAGS=extended mage install etc.
@@ -345,4 +358,24 @@
return envtags
}
return "none"
+}
+
+func argsToStrings(v ...interface{}) []string {
+ var args []string
+ for _, arg := range v {
+ switch v := arg.(type) {
+ case string:
+ if v != "" {
+ args = append(args, v)
+ }
+ case []string:
+ if v != nil {
+ args = append(args, v...)
+ }
+ default:
+ panic("invalid type")
+ }
+ }
+
+ return args
}
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -26,7 +26,7 @@
hugo:
plugin: nil
- build-snaps: [go/1.14/stable]
+ build-snaps: [go/1.15/stable]
source: .
override-build: |
set -ex