Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Go 1.16 #8015

Merged
merged 9 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defaults: &defaults
docker:
- image: bepsays/ci-goreleaser:1.15.1
- image: bepsays/ci-goreleaser:1.16.0-2
environment:
CGO_ENABLED: "0"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
GO111MODULE: on
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
go-version: [1.16.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Use the [installation instructions in the Hugo documentation](https://gohugo.io/
#### Prerequisite Tools

* [Git](https://git-scm.com/)
* [Go (we test it with the last 2 major versions)](https://golang.org/dl/)
* [Go (we test it with the last 2 major versions; but note that Hugo 0.81.0 only builds with >= Go 1.16.)](https://golang.org/dl/)

#### Fetch from GitHub

Expand Down
149 changes: 149 additions & 0 deletions go.sum

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ builds:
-
binary: hugo
id: hugo
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }} -X github.com/gohugoio/hugo/common/hugo.vendorInfo=gohugoio
env:
- CGO_ENABLED=0
flags:
Expand Down Expand Up @@ -38,7 +38,7 @@ builds:
binary: hugo
id: hugo_extended_windows
ldflags:
- -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
- -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }} -X github.com/gohugoio/hugo/common/hugo.vendorInfo=gohugoio
- "-extldflags '-static'"
env:
- CGO_ENABLED=1
Expand All @@ -55,7 +55,7 @@ builds:
- amd64
- binary: hugo
id: hugo_extended_darwin
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }} -X github.com/gohugoio/hugo/common/hugo.vendorInfo=gohugoio
env:
- CGO_ENABLED=1
- CC=o64-clang
Expand All @@ -69,9 +69,10 @@ builds:
- darwin
goarch:
- amd64
- arm64
- binary: hugo
id: hugo_extended_linux
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }}
ldflags: -s -w -X github.com/gohugoio/hugo/common/hugo.buildDate={{.Date}} -X github.com/gohugoio/hugo/common/hugo.commitHash={{ .ShortCommit }} -X github.com/gohugoio/hugo/common/hugo.vendorInfo=gohugoio
env:
- CGO_ENABLED=1
flags:
Expand All @@ -83,7 +84,6 @@ builds:
- linux
goarch:
- amd64

release:
draft: true

Expand Down Expand Up @@ -146,7 +146,7 @@ nfpms:
maintainer: "Bjørn Erik Pedersen <[email protected]>"
description: "A Fast and Flexible Static Site Generator built with love in GoLang."
license: "Apache 2.0"
name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}"
file_name_template: "{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}"
replacements:
amd64: 64bit
386: 32bit
Expand All @@ -169,7 +169,7 @@ nfpms:
maintainer: "Bjørn Erik Pedersen <[email protected]>"
description: "A Fast and Flexible Static Site Generator built with love in GoLang."
license: "Apache 2.0"
name_template: "{{.ProjectName}}_extended_{{.Version}}_{{.Os}}-{{.Arch}}"
file_name_template: "{{.ProjectName}}_extended_{{.Version}}_{{.Os}}-{{.Arch}}"
replacements:
amd64: 64bit
386: 32bit
Expand Down
60 changes: 0 additions & 60 deletions hugolib/embedded_templates_norace_test.go

This file was deleted.

39 changes: 39 additions & 0 deletions hugolib/embedded_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ package hugolib

import (
"testing"

qt "github.com/frankban/quicktest"
)

func TestInternalTemplatesImage(t *testing.T) {
Expand Down Expand Up @@ -77,3 +79,40 @@ title: My Site
<meta itemprop="image" content="https://example.org/siteimg1.jpg"/>
`)
}

// Just some simple test of the embedded templates to avoid
// https://github.com/gohugoio/hugo/issues/4757 and similar.
func TestEmbeddedTemplates(t *testing.T) {
t.Parallel()

c := qt.New(t)
c.Assert(true, qt.Equals, true)

home := []string{"index.html", `
GA:
{{ template "_internal/google_analytics.html" . }}

GA async:

{{ template "_internal/google_analytics_async.html" . }}

Disqus:

{{ template "_internal/disqus.html" . }}

`}

b := newTestSitesBuilder(t)
b.WithSimpleConfigFile().WithTemplatesAdded(home...)

b.Build(BuildCfg{})

// Gheck GA regular and async
b.AssertFileContent("public/index.html",
"'anonymizeIp', true",
"'script','https://www.google-analytics.com/analytics.js','ga');\n\tga('create', 'ga_id', 'auto')",
"<script async src='https://www.google-analytics.com/analytics.js'>")

// Disqus
b.AssertFileContent("public/index.html", "\"disqus_shortname\" + '.disqus.com/embed.js';")
}
21 changes: 21 additions & 0 deletions hugolib/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,13 +584,34 @@ func TestTemplateGoIssues(t *testing.T) {
"index.html", `
{{ $title := "a & b" }}
<script type="application/ld+json">{"@type":"WebPage","headline":"{{$title}}"}</script>

{{/* Action/commands newlines, from Go 1.16, see https://github.com/golang/go/issues/29770 */}}
{{ $norway := dict
"country" "Norway"
"population" "5 millions"
"language" "Norwegian"
"language_code" "nb"
"weather" "freezing cold"
"capitol" "Oslo"
"largest_city" "Oslo"
"currency" "Norwegian krone"
"dialing_code" "+47"
}}

Population in Norway is {{
$norway.population
| lower
| upper
}}

`,
)

b.Build(BuildCfg{})

b.AssertFileContent("public/index.html", `
<script type="application/ld+json">{"@type":"WebPage","headline":"a \u0026 b"}</script>
Population in Norway is 5 MILLIONS

`)
}
Expand Down
2 changes: 1 addition & 1 deletion releaser/releaser.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (r *ReleaseHandler) release(releaseNotesFile string) error {
return nil
}

args := []string{"--rm-dist", "--release-notes", releaseNotesFile}
args := []string{"--parallelism", "3", "--rm-dist", "--release-notes", releaseNotesFile}
if r.skipPublish {
args = append(args, "--skip-publish")
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/fork_go_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

func main() {
// TODO(bep) git checkout tag
// The current is built with Go version b68fa57c599720d33a2d735782969ce95eabf794 / go1.15dev
// The current is built with Go version 2f0da6d9e29d9b9d5a4d10427ca9f71d12bbacc8 / go1.16
fmt.Println("Forking ...")
defer fmt.Println("Done ...")

Expand Down Expand Up @@ -75,6 +75,7 @@ var (
"\"text/template\"\n", "template \"github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate\"\n",
`"html/template"`, `htmltemplate "html/template"`,
`"fmt"`, `htmltemplate "html/template"`,
`t.Skip("this test currently fails with -race; see issue #39807")`, `// t.Skip("this test currently fails with -race; see issue #39807")`,
)
)

Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ parts:

hugo:
plugin: nil
build-snaps: [go/1.15/stable]
build-snaps: [go/1.16/stable]
source: .
override-build: |
set -ex
Expand Down
1 change: 1 addition & 0 deletions tpl/internal/go_templates/cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const KnownEnv = `
GOSUMDB
GOTMPDIR
GOTOOLDIR
GOVCS
GOWASM
GO_EXTLINK_ENABLED
PKG_CONFIG
Expand Down
2 changes: 1 addition & 1 deletion tpl/internal/go_templates/fmtsort/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func compare(aVal, bVal reflect.Value) int {
default:
return -1
}
case reflect.Ptr:
case reflect.Ptr, reflect.UnsafePointer:
a, b := aVal.Pointer(), bVal.Pointer()
switch {
case a < b:
Expand Down
22 changes: 22 additions & 0 deletions tpl/internal/go_templates/fmtsort/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"reflect"
"strings"
"testing"
"unsafe"
)

var compareTests = [][]reflect.Value{
Expand All @@ -32,6 +33,7 @@ var compareTests = [][]reflect.Value{
ct(reflect.TypeOf(complex128(0+1i)), -1-1i, -1+0i, -1+1i, 0-1i, 0+0i, 0+1i, 1-1i, 1+0i, 1+1i),
ct(reflect.TypeOf(false), false, true),
ct(reflect.TypeOf(&ints[0]), &ints[0], &ints[1], &ints[2]),
ct(reflect.TypeOf(unsafe.Pointer(&ints[0])), unsafe.Pointer(&ints[0]), unsafe.Pointer(&ints[1]), unsafe.Pointer(&ints[2])),
ct(reflect.TypeOf(chans[0]), chans[0], chans[1], chans[2]),
ct(reflect.TypeOf(toy{}), toy{0, 1}, toy{0, 2}, toy{1, -1}, toy{1, 1}),
ct(reflect.TypeOf([2]int{}), [2]int{1, 1}, [2]int{1, 2}, [2]int{2, 0}),
Expand Down Expand Up @@ -118,6 +120,10 @@ var sortTests = []sortTest{
pointerMap(),
"PTR0:0 PTR1:1 PTR2:2",
},
{
unsafePointerMap(),
"UNSAFEPTR0:0 UNSAFEPTR1:1 UNSAFEPTR2:2",
},
{
map[toy]string{{7, 2}: "72", {7, 1}: "71", {3, 4}: "34"},
"{3 4}:34 {7 1}:71 {7 2}:72",
Expand Down Expand Up @@ -159,6 +165,14 @@ func sprintKey(key reflect.Value) string {
}
}
return "PTR???"
case "unsafe.Pointer":
ptr := key.Interface().(unsafe.Pointer)
for i := range ints {
if ptr == unsafe.Pointer(&ints[i]) {
return fmt.Sprintf("UNSAFEPTR%d", i)
}
}
return "UNSAFEPTR???"
case "chan int":
c := key.Interface().(chan int)
for i := range chans {
Expand All @@ -185,6 +199,14 @@ func pointerMap() map[*int]string {
return m
}

func unsafePointerMap() map[unsafe.Pointer]string {
m := make(map[unsafe.Pointer]string)
for i := 2; i >= 0; i-- {
m[unsafe.Pointer(&ints[i])] = fmt.Sprint(i)
}
return m
}

func chanMap() map[chan int]string {
m := make(map[chan int]string)
for i := 2; i >= 0; i-- {
Expand Down
Loading