Skip to content

Commit 1288dcd

Browse files
committed
Merge remote-tracking branch 'upstream/release-branch.go1.26' into golang-1.26-haiku
2 parents b625b4a + e87b10e commit 1288dcd

27 files changed

+269
-220
lines changed

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
go1.26.0
2-
time 2026-02-10T01:22:00Z
1+
go1.26.1
2+
time 2026-03-05T20:45:11Z

doc/godebug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
155155

156156
### Go 1.26
157157

158+
Go 1.26.1 added a new `htmlmetacontenturlescape` setting that controls whether
159+
html/template will escape URLs in the `url=` portion of the content attribute of
160+
HTML meta tags. The default `htmlmetacontentescape=1` will cause URLs to be
161+
escaped. Setting `htmlmetacontentescape=0` disables this behavior.
162+
158163
Go 1.26 added a new `httpcookiemaxnum` setting that controls the maximum number
159164
of cookies that net/http will accept when parsing HTTP headers. If the number of
160165
cookie in a header exceeds the number set in `httpcookiemaxnum`, cookie parsing

src/cmd/go/internal/modload/init.go

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"cmd/go/internal/lockedfile"
3030
"cmd/go/internal/modfetch"
3131
"cmd/go/internal/search"
32-
igover "internal/gover"
3332

3433
"golang.org/x/mod/modfile"
3534
"golang.org/x/mod/module"
@@ -838,7 +837,7 @@ func WriteWorkFile(path string, wf *modfile.WorkFile) error {
838837
wf.Cleanup()
839838
out := modfile.Format(wf.Syntax)
840839

841-
return os.WriteFile(path, out, 0o666)
840+
return os.WriteFile(path, out, 0666)
842841
}
843842

844843
// UpdateWorkGoVersion updates the go line in wf to be at least goVers,
@@ -1212,7 +1211,7 @@ func CreateModFile(loaderstate *State, ctx context.Context, modPath string) {
12121211
modFile := new(modfile.File)
12131212
modFile.AddModuleStmt(modPath)
12141213
loaderstate.MainModules = makeMainModules(loaderstate, []module.Version{modFile.Module.Mod}, []string{modRoot}, []*modfile.File{modFile}, []*modFileIndex{nil}, nil)
1215-
addGoStmt(modFile, modFile.Module.Mod, DefaultModInitGoVersion()) // Add the go directive before converted module requirements.
1214+
addGoStmt(modFile, modFile.Module.Mod, gover.Local()) // Add the go directive before converted module requirements.
12161215

12171216
rs := requirementsFromModFiles(loaderstate, ctx, nil, []*modfile.File{modFile}, nil)
12181217
rs, err := updateRoots(loaderstate, ctx, rs.direct, rs, nil, nil, false)
@@ -1823,7 +1822,9 @@ Run 'go help mod init' for more information.
18231822
return "", fmt.Errorf(msg, dir, reason)
18241823
}
18251824

1826-
var importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`)
1825+
var (
1826+
importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`)
1827+
)
18271828

18281829
func findImportComment(file string) string {
18291830
data, err := os.ReadFile(file)
@@ -2262,29 +2263,3 @@ func CheckGodebug(verb, k, v string) error {
22622263
}
22632264
return fmt.Errorf("unknown %s %q", verb, k)
22642265
}
2265-
2266-
// DefaultModInitGoVersion returns the appropriate go version to include in a
2267-
// newly initialized module or work file.
2268-
//
2269-
// If the current toolchain version is a stable version of Go 1.N.M, default to
2270-
// go 1.(N-1).0
2271-
//
2272-
// If the current toolchain version is a pre-release version of Go 1.N (Release
2273-
// Candidate M) or a development version of Go 1.N, default to go 1.(N-2).0
2274-
func DefaultModInitGoVersion() string {
2275-
v := gover.Local()
2276-
if isPrereleaseOrDevelVersion(v) {
2277-
v = gover.Prev(gover.Prev(v))
2278-
} else {
2279-
v = gover.Prev(v)
2280-
}
2281-
if strings.Count(v, ".") < 2 {
2282-
v += ".0"
2283-
}
2284-
return v
2285-
}
2286-
2287-
func isPrereleaseOrDevelVersion(s string) bool {
2288-
v := igover.Parse(s)
2289-
return v.Kind != "" || v.Patch == ""
2290-
}

src/cmd/go/internal/workcmd/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"cmd/go/internal/base"
1414
"cmd/go/internal/fsys"
15+
"cmd/go/internal/gover"
1516
"cmd/go/internal/modload"
1617

1718
"golang.org/x/mod/modfile"
@@ -57,9 +58,10 @@ func runInit(ctx context.Context, cmd *base.Command, args []string) {
5758
base.Fatalf("go: %s already exists", gowork)
5859
}
5960

61+
goV := gover.Local() // Use current Go version by default
6062
wf := new(modfile.WorkFile)
6163
wf.Syntax = new(modfile.FileSyntax)
62-
wf.AddGoStmt(modload.DefaultModInitGoVersion())
64+
wf.AddGoStmt(goV)
6365
workUse(ctx, moduleLoaderState, gowork, wf, args)
6466
modload.WriteWorkFile(gowork, wf)
6567
}

src/cmd/go/testdata/script/mod_edit.txt

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
env GO111MODULE=on
22

3-
# Set go version so that we can test produced mod files for equality.
4-
env TESTGO_VERSION=go1.26.0
5-
63
# Test that go mod edits and related mod flags work.
74
# Also test that they can use a dummy name that isn't resolvable. golang.org/issue/24100
85

@@ -13,16 +10,16 @@ stderr 'cannot determine module path'
1310

1411
go mod init x.x/y/z
1512
stderr 'creating new go.mod: module x.x/y/z'
16-
cmp go.mod $WORK/go.mod.init
13+
cmpenv go.mod $WORK/go.mod.init
1714

1815
! go mod init
19-
cmp go.mod $WORK/go.mod.init
16+
cmpenv go.mod $WORK/go.mod.init
2017

2118
# go mod edits
2219
go mod edit -droprequire=x.1 -require=x.1@v1.0.0 -require=x.2@v1.1.0 -droprequire=x.2 -exclude='x.1 @ v1.2.0' -exclude=x.1@v1.2.1 -exclude=x.1@v2.0.0+incompatible -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z' -retract=v1.6.0 -retract=[v1.1.0,v1.2.0] -retract=[v1.3.0,v1.4.0] -retract=v1.0.0
23-
cmp go.mod $WORK/go.mod.edit1
20+
cmpenv go.mod $WORK/go.mod.edit1
2421
go mod edit -droprequire=x.1 -dropexclude=x.1@v1.2.1 -dropexclude=x.1@v2.0.0+incompatible -dropreplace=x.1@v1.3.0 -require=x.3@v1.99.0 -dropretract=v1.0.0 -dropretract=[v1.1.0,v1.2.0]
25-
cmp go.mod $WORK/go.mod.edit2
22+
cmpenv go.mod $WORK/go.mod.edit2
2623

2724
# -exclude and -retract reject invalid versions.
2825
! go mod edit -exclude=example.com/m@bad
@@ -39,11 +36,11 @@ stderr '^go: -exclude=example.com/m/v2@v1\.0\.0: version "v1\.0\.0" invalid: sho
3936
! go mod edit -exclude=gopkg.in/example.v1@v2.0.0
4037
stderr '^go: -exclude=gopkg\.in/example\.v1@v2\.0\.0: version "v2\.0\.0" invalid: should be v1, not v2$'
4138

42-
cmp go.mod $WORK/go.mod.edit2
39+
cmpenv go.mod $WORK/go.mod.edit2
4340

4441
# go mod edit -json
4542
go mod edit -json
46-
cmp stdout $WORK/go.mod.json
43+
cmpenv stdout $WORK/go.mod.json
4744

4845
# go mod edit -json (retractions with rationales)
4946
go mod edit -json $WORK/go.mod.retractrationale
@@ -59,66 +56,66 @@ cmp stdout $WORK/go.mod.empty.json
5956

6057
# go mod edit -replace
6158
go mod edit -replace=x.1@v1.3.0=y.1/v2@v2.3.5 -replace=x.1@v1.4.0=y.1/v2@v2.3.5
62-
cmp go.mod $WORK/go.mod.edit3
59+
cmpenv go.mod $WORK/go.mod.edit3
6360
go mod edit -replace=x.1=y.1/v2@v2.3.6
64-
cmp go.mod $WORK/go.mod.edit4
61+
cmpenv go.mod $WORK/go.mod.edit4
6562
go mod edit -dropreplace=x.1
66-
cmp go.mod $WORK/go.mod.edit5
63+
cmpenv go.mod $WORK/go.mod.edit5
6764
go mod edit -replace=x.1=../y.1/@v2
68-
cmp go.mod $WORK/go.mod.edit6
65+
cmpenv go.mod $WORK/go.mod.edit6
6966
! go mod edit -replace=x.1=y.1/@v2
7067
stderr '^go: -replace=x.1=y.1/@v2: invalid new path: malformed import path "y.1/": trailing slash$'
7168

7269
# go mod edit -fmt
7370
cp $WORK/go.mod.badfmt go.mod
7471
go mod edit -fmt -print # -print should avoid writing file
75-
cmp stdout $WORK/go.mod.goodfmt
72+
cmpenv stdout $WORK/go.mod.goodfmt
7673
cmp go.mod $WORK/go.mod.badfmt
7774
go mod edit -fmt # without -print, should write file (and nothing to stdout)
7875
! stdout .
79-
cmp go.mod $WORK/go.mod.goodfmt
76+
cmpenv go.mod $WORK/go.mod.goodfmt
8077

8178
# go mod edit -module
8279
cd $WORK/m
8380
go mod init a.a/b/c
8481
go mod edit -module x.x/y/z
85-
cmp go.mod go.mod.edit
82+
cmpenv go.mod go.mod.edit
8683

8784
# golang.org/issue/30513: don't require go-gettable module paths.
8885
cd $WORK/local
8986
go mod init foo
9087
go mod edit -module local-only -require=other-local@v1.0.0 -replace other-local@v1.0.0=./other
91-
cmp go.mod go.mod.edit
88+
cmpenv go.mod go.mod.edit
9289

9390
# go mod edit -godebug
9491
cd $WORK/g
9592
cp go.mod.start go.mod
9693
go mod edit -godebug key=value
97-
cmp go.mod go.mod.edit
94+
cmpenv go.mod go.mod.edit
9895
go mod edit -dropgodebug key2
99-
cmp go.mod go.mod.edit
96+
cmpenv go.mod go.mod.edit
10097
go mod edit -dropgodebug key
101-
cmp go.mod go.mod.start
98+
cmpenv go.mod go.mod.start
10299

103100
# go mod edit -tool
104101
cd $WORK/h
105102
cp go.mod.start go.mod
106103
go mod edit -tool example.com/tool
107-
cmp go.mod go.mod.edit
104+
cmpenv go.mod go.mod.edit
108105
go mod edit -droptool example.com/tool2
109-
cmp go.mod go.mod.edit
106+
cmpenv go.mod go.mod.edit
110107
go mod edit -droptool example.com/tool
111-
cmp go.mod go.mod.start
108+
cmpenv go.mod go.mod.start
112109

113110
# go mod edit -ignore
114111
cd $WORK/i
115112
cp go.mod.start go.mod
116113
go mod edit -ignore example.com/ignore
117-
cmp go.mod go.mod.edit
114+
cmpenv go.mod go.mod.edit
118115
go mod edit -dropignore example.com/ignore2
119-
cmp go.mod go.mod.edit
116+
cmpenv go.mod go.mod.edit
120117
go mod edit -dropignore example.com/ignore
121-
cmp go.mod go.mod.start
118+
cmpenv go.mod go.mod.start
122119

123120
-- x.go --
124121
package x
@@ -129,11 +126,11 @@ package w
129126
-- $WORK/go.mod.init --
130127
module x.x/y/z
131128

132-
go 1.25.0
129+
go $goversion
133130
-- $WORK/go.mod.edit1 --
134131
module x.x/y/z
135132

136-
go 1.25.0
133+
go $goversion
137134

138135
require x.1 v1.0.0
139136

@@ -157,7 +154,7 @@ retract (
157154
-- $WORK/go.mod.edit2 --
158155
module x.x/y/z
159156

160-
go 1.25.0
157+
go $goversion
161158

162159
exclude x.1 v1.2.0
163160

@@ -174,7 +171,7 @@ require x.3 v1.99.0
174171
"Module": {
175172
"Path": "x.x/y/z"
176173
},
177-
"Go": "1.25.0",
174+
"Go": "$goversion",
178175
"Require": [
179176
{
180177
"Path": "x.3",
@@ -214,7 +211,7 @@ require x.3 v1.99.0
214211
-- $WORK/go.mod.edit3 --
215212
module x.x/y/z
216213

217-
go 1.25.0
214+
go $goversion
218215

219216
exclude x.1 v1.2.0
220217

@@ -232,7 +229,7 @@ require x.3 v1.99.0
232229
-- $WORK/go.mod.edit4 --
233230
module x.x/y/z
234231

235-
go 1.25.0
232+
go $goversion
236233

237234
exclude x.1 v1.2.0
238235

@@ -247,7 +244,7 @@ require x.3 v1.99.0
247244
-- $WORK/go.mod.edit5 --
248245
module x.x/y/z
249246

250-
go 1.25.0
247+
go $goversion
251248

252249
exclude x.1 v1.2.0
253250

@@ -260,7 +257,7 @@ require x.3 v1.99.0
260257
-- $WORK/go.mod.edit6 --
261258
module x.x/y/z
262259

263-
go 1.25.0
260+
go $goversion
264261

265262
exclude x.1 v1.2.0
266263

@@ -275,7 +272,7 @@ replace x.1 => ../y.1/@v2
275272
-- $WORK/local/go.mod.edit --
276273
module local-only
277274

278-
go 1.25.0
275+
go $goversion
279276

280277
require other-local v1.0.0
281278

@@ -307,7 +304,7 @@ retract [v1.8.1, v1.8.2]
307304
-- $WORK/m/go.mod.edit --
308305
module x.x/y/z
309306

310-
go 1.25.0
307+
go $goversion
311308
-- $WORK/go.mod.retractrationale --
312309
module x.x/y/z
313310

@@ -408,4 +405,4 @@ module g
408405

409406
go 1.24
410407

411-
ignore example.com/ignore
408+
ignore example.com/ignore

src/cmd/go/testdata/script/mod_init_version.txt

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/cmd/go/testdata/script/work.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[short] skip 'runs go run'
2-
env TESTGO_VERSION=go1.26.0
32

43
! go work init doesnotexist
54
stderr 'go: directory doesnotexist does not exist'
@@ -75,7 +74,7 @@ use (
7574
../src/a
7675
)
7776
-- go.work.want --
78-
go 1.25.0
77+
go $goversion
7978

8079
use (
8180
./a

0 commit comments

Comments
 (0)