Skip to content

Commit fd8b0fb

Browse files
committed
Upgrade to Go 1.24
Fixes #13381
1 parent 9b5f786 commit fd8b0fb

37 files changed

+653
-567
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parameters:
44
defaults: &defaults
55
resource_class: large
66
docker:
7-
- image: bepsays/ci-hugoreleaser:1.22301.20401
7+
- image: bepsays/ci-hugoreleaser:1.22400.20000
88
environment: &buildenv
99
GOMODCACHE: /root/project/gomodcache
1010
version: 2
@@ -58,7 +58,7 @@ jobs:
5858
environment:
5959
<<: [*buildenv]
6060
docker:
61-
- image: bepsays/ci-hugoreleaser-linux-arm64:1.22301.20401
61+
- image: bepsays/ci-hugoreleaser-linux-arm64:1.22400.20000
6262
steps:
6363
- *restore-cache
6464
- &attach-workspace

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
test:
1717
strategy:
1818
matrix:
19-
go-version: [1.22.x, 1.23.x]
19+
go-version: [1.23.x, 1.24.x]
2020
os: [ubuntu-latest, windows-latest] # macos disabled for now because of disk space issues.
2121
runs-on: ${{ matrix.os }}
2222
steps:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ require (
170170
software.sslmate.com/src/go-pkcs12 v0.2.0 // indirect
171171
)
172172

173-
go 1.22.6
173+
go 1.23

scripts/fork_go_templates/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
func main() {
19-
// The current is built with 6885bad7dd86880be6929c02085e5c7a67ff2887 go1.23.0
19+
// The current is built with 3901409b5d [release-branch.go1.24] go1.24.0
2020
// TODO(bep) preserve the staticcheck.conf file.
2121
fmt.Println("Forking ...")
2222
defer fmt.Println("Done ...")
@@ -216,6 +216,7 @@ func rewrite(filename, rule string) {
216216
}
217217

218218
func goimports(dir string) {
219+
// Needs go install golang.org/x/tools/cmd/goimports@latest
219220
cmf, _ := hexec.SafeCommand("goimports", "-w", dir)
220221
out, err := cmf.CombinedOutput()
221222
if err != nil {

tpl/internal/go_templates/cfg/cfg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ const KnownEnv = `
3737
GOARCH
3838
GOARM
3939
GOARM64
40+
GOAUTH
4041
GOBIN
4142
GOCACHE
4243
GOCACHEPROG
4344
GOENV
4445
GOEXE
4546
GOEXPERIMENT
47+
GOFIPS140
4648
GOFLAGS
4749
GOGCCFLAGS
4850
GOHOSTARCH

tpl/internal/go_templates/htmltemplate/clone_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !windows
6-
// +build !windows
5+
//go:build go1.13 && !windows
6+
// +build go1.13,!windows
77

88
package template
99

tpl/internal/go_templates/htmltemplate/content_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !windows
6-
// +build !windows
5+
//go:build go1.13 && !windows
6+
// +build go1.13,!windows
77

88
package template
99

@@ -428,7 +428,7 @@ func TestStringer(t *testing.T) {
428428
if err := tmpl.Execute(b, s); err != nil {
429429
t.Fatal(err)
430430
}
431-
expect := "string=3"
431+
var expect = "string=3"
432432
if b.String() != expect {
433433
t.Errorf("expected %q got %q", expect, b.String())
434434
}

tpl/internal/go_templates/htmltemplate/css_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !windows
6-
// +build !windows
5+
//go:build go1.13 && !windows
6+
// +build go1.13,!windows
77

88
package template
99

tpl/internal/go_templates/htmltemplate/escape.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"html"
1111
"io"
12+
"maps"
1213
"regexp"
1314

1415
template "github.com/gohugoio/hugo/tpl/internal/go_templates/texttemplate"
@@ -145,7 +146,7 @@ func (e *escaper) escape(c context, n parse.Node) context {
145146
return c
146147
case *parse.ContinueNode:
147148
c.n = n
148-
e.rangeContext.continues = append(e.rangeContext.breaks, c)
149+
e.rangeContext.continues = append(e.rangeContext.continues, c)
149150
return context{state: stateDead}
150151
case *parse.IfNode:
151152
return e.escapeBranch(c, &n.BranchNode, "if")
@@ -588,22 +589,14 @@ func (e *escaper) escapeListConditionally(c context, n *parse.ListNode, filter f
588589
e1 := makeEscaper(e.ns)
589590
e1.rangeContext = e.rangeContext
590591
// Make type inferences available to f.
591-
for k, v := range e.output {
592-
e1.output[k] = v
593-
}
592+
maps.Copy(e1.output, e.output)
594593
c = e1.escapeList(c, n)
595594
ok := filter != nil && filter(&e1, c)
596595
if ok {
597596
// Copy inferences and edits from e1 back into e.
598-
for k, v := range e1.output {
599-
e.output[k] = v
600-
}
601-
for k, v := range e1.derived {
602-
e.derived[k] = v
603-
}
604-
for k, v := range e1.called {
605-
e.called[k] = v
606-
}
597+
maps.Copy(e.output, e1.output)
598+
maps.Copy(e.derived, e1.derived)
599+
maps.Copy(e.called, e1.called)
607600
for k, v := range e1.actionNodeEdits {
608601
e.editActionNode(k, v)
609602
}

tpl/internal/go_templates/htmltemplate/escape_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !windows
6-
// +build !windows
5+
//go:build go1.13 && !windows
6+
// +build go1.13,!windows
77

88
package template
99

@@ -944,6 +944,7 @@ func TestEscapeSet(t *testing.T) {
944944
t.Errorf("want\n\t%q\ngot\n\t%q", test.want, got)
945945
}
946946
}
947+
947948
}
948949

949950
func TestErrors(t *testing.T) {
@@ -1064,6 +1065,10 @@ func TestErrors(t *testing.T) {
10641065
"{{range .Items}}<a{{if .X}}{{continue}}{{end}}>{{end}}",
10651066
"z:1:29: at range loop continue: {{range}} branches end in different contexts",
10661067
},
1068+
{
1069+
"{{range .Items}}{{if .X}}{{break}}{{end}}<a{{if .Y}}{{continue}}{{end}}>{{if .Z}}{{continue}}{{end}}{{end}}",
1070+
"z:1:54: at range loop continue: {{range}} branches end in different contexts",
1071+
},
10671072
{
10681073
"<a b=1 c={{.H}}",
10691074
"z: ends in a non-text context: {stateAttr delimSpaceOrTagEnd",
@@ -1193,6 +1198,7 @@ func TestErrors(t *testing.T) {
11931198
// Check that we get the same error if we call Execute again.
11941199
if err := tmpl.Execute(buf, nil); err == nil || err.Error() != got {
11951200
t.Errorf("input=%q: unexpected error on second call %q", test.input, err)
1201+
11961202
}
11971203
}
11981204
}

0 commit comments

Comments
 (0)