Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5500cbf
debug/elf: prevent offset overflow
callthingsoff Sep 25, 2025
6d51f93
runtime: jump instead of branch in netbsd/arm64 entry point
qmuntal Sep 29, 2025
d42d56b
encoding/xml: make use of reflect.TypeAssert
apocelipes Sep 24, 2025
fe3ba74
cmd/link: skip TestFlagW on platforms without DWARF symbol table
millerresearch Sep 27, 2025
ae8eba0
cmd/link: use correct length for pcln.cutab
ianlancetaylor Sep 29, 2025
047c2ab
cmd/link: don't pass -Wl,-S on Solaris
cherrymui Sep 26, 2025
4e9006a
crypto/tls: quote protocols in ALPN error message
rolandshoemaker Sep 29, 2025
4b77733
internal/syscall/windows: regenerate GetFileSizeEx
qmuntal Sep 29, 2025
eaf2345
cmd/link: use a .def file to mark exported symbols on Windows
qmuntal Sep 22, 2025
690fc2f
internal/poll: remove buf field from operation
qmuntal Sep 16, 2025
db3cb3f
runtime: correct reference to getStackMap in comment
ianlancetaylor Sep 29, 2025
db4fade
crypto/internal/fips140/mlkem: make CAST conditional
FiloSottile Sep 22, 2025
fc88e18
crypto/internal/fips140/entropy: add CPU jitter-based entropy source
FiloSottile Sep 11, 2025
75c87df
internal/poll: pass the I/O mode instead of an overlapped object in e…
qmuntal Sep 16, 2025
db10db6
internal/poll: remove operation fields from FD
qmuntal Sep 16, 2025
742f920
cmd/compile, runtime: always enable Wasm signext and satconv features
cherrymui Sep 29, 2025
6e95748
cmd/link/internal/arm64: support Mach-O ARM64_RELOC_POINTER_TO_GOT in…
qmuntal Sep 12, 2025
7c8166d
cmd/link/internal/arm64: support Mach-O ARM64_RELOC_SUBTRACTOR in int…
qmuntal Sep 12, 2025
a846bb0
errors: add AsType
jub0bs Sep 29, 2025
300d9d2
runtime: initialise debug settings much earlier in startup process
9muir Sep 18, 2025
97da068
cmd/compile: eliminate nil checks on .dict arg
jakebailey Sep 8, 2025
08afc50
mime: extend "builtinTypes" to include a more complete list of common…
AidanWelch Sep 25, 2025
19cc102
mime: reduce allocs incurred by ParseMediaType
jub0bs Sep 22, 2025
fcb893f
cmd/compile/internal/ssa: remove redundant "type:" prefix check
fengyoulin Sep 5, 2025
4ff8a45
test/codegen: codify handling of floating point constants on arm64
4a6f656c Sep 15, 2025
c925715
runtime: unify ppc64/ppc64le library entry point
qmuntal Sep 24, 2025
eb1c7f6
runtime: move loong64 library entry point to os-agnostic file
qmuntal Sep 24, 2025
be0fed8
cmd/go/testdata/script/test_fuzz_fuzztime.txt: disable
adonovan Sep 30, 2025
3f451f2
testing/synctest: fix inverted test failure message in TestContextAft…
fgm Oct 1, 2025
8ad27fb
doc/go_spec.html: update date
adonovan Oct 1, 2025
633dd1d
encoding/json: fix Decoder.InputOffset regression in goexperiment.jsonv2
dsnet Sep 15, 2025
5799c13
crypto/tls: rm marshalEncryptedClientHelloConfigList dead code
cpu Sep 29, 2025
84db201
cmd/compile: propagate len([]T{}) to make builtin to allow stack allo…
mateusz834 Sep 26, 2025
8c68a1c
runtime,net/http/pprof: goroutine leak detection by using the garbage…
VladSaiocUber Oct 2, 2025
707454b
cmd/go: update `go help mod edit` with the tool and ignore sections
mvdan Aug 30, 2025
f03c392
runtime: fix aix/ppc64 library initialization
qmuntal Oct 1, 2025
0e4e2e6
runtime: skip TestGoroutineLeakProfile under mayMoreStackPreempt
mknyszek Oct 2, 2025
4008e07
io/fs: move path name documentation up to the package doc comment
neild Oct 2, 2025
bbdff9e
net/http: update bundled x/net/http2 and delete obsolete http2inTests
nicholashusin Oct 2, 2025
5384500
net/http/httputil: deprecate ReverseProxy.Director
neild Oct 2, 2025
d5b9503
cmd/cgo: fix unaligned arguments typedmemmove crash on iOS
timcooijmans Sep 30, 2025
adce7f1
cmd/link: support .def file with MSVC clang toolchain
cherrymui Oct 2, 2025
630799c
crypto/tls: add flag to render HTML BoGo report
cpu Jun 30, 2025
a7917ee
internal/buildcfg: enable specializedmalloc experiment
matloob Mar 17, 2025
c54dc14
runtime: support valgrind (but not asan) in specialized malloc functions
matloob Oct 1, 2025
ebb72be
cmd/compile: don't treat devel compiler as a released compiler
cherrymui Jun 20, 2025
ab04395
cmd/compile: minor tweak for race detector
dr2chase Jul 2, 2025
10e7968
cmd/compile: accounts rematerialize ops's output reginfo
JunyangShao Aug 12, 2025
ec70d19
cmd/compile: rewrite to elide Slicemask from len==c>0 slicing
dr2chase Aug 20, 2025
1caa95a
cmd/compile: enhance prove to deal with double-offset IsInBounds checks
dr2chase Sep 3, 2025
18cd4a1
cmd/compile: use the right type for spill slot
cherrymui Sep 16, 2025
ad3db25
cmd/compile: handle rematerialized op for incompatible reg constraint
JunyangShao Sep 16, 2025
20c9377
cmd/compile: enhance the chunked indexing case to include reslicing
dr2chase Sep 17, 2025
d91148c
cmd/compile: enhance prove to infer bounds in slice len/cap calculations
dr2chase Sep 17, 2025
003b5ce
cmd/compile: fix SIMD const rematerialization condition
JunyangShao Sep 19, 2025
38b26f2
cmd/compile: remove stores to unread parameters
cherrymui Sep 22, 2025
1bca4c1
cmd/compile: improve slicemask removal
dr2chase Sep 17, 2025
ee5369b
cmd/link: add LIBRARY statement only with -buildmode=cshared
qmuntal Oct 3, 2025
2a71af1
net/url: improve URL docs
mateusz834 Sep 24, 2025
97a2233
lib/wasm: eliminate global namespace pollution in wasm_exec.js
alexgleason Oct 6, 2025
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
1 change: 1 addition & 0 deletions api/next/51945.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg errors, func AsType[$0 error](error) ($0, bool) #51945
1 change: 1 addition & 0 deletions api/next/73161.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg net/http/httputil, type ReverseProxy struct, Director //deprecated #73161
2 changes: 1 addition & 1 deletion doc/go_spec.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Language version go1.25 (Feb 25, 2025)",
"Subtitle": "Language version go1.26 (Oct 1, 2025)",
"Path": "/ref/spec"
}-->

Expand Down
2 changes: 2 additions & 0 deletions doc/next/6-stdlib/99-minor/errors/51945.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The new [AsType] function is a generic version of [As]. It is type-safe, faster,
and, in most cases, easier to use.
11 changes: 11 additions & 0 deletions doc/next/6-stdlib/99-minor/net/http/httputil/73161.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The [ReverseProxy.Director] configuration field is deprecated
in favor of [ReverseProxy.Rewrite].

A malicious client can remove headers added by a `Director` function
by designating those headers as hop-by-hop. Since there is no way to address
this problem within the scope of the `Director` API, we added a new
`Rewrite` hook in Go 1.20. `Rewrite` hooks are provided with both the
unmodified inbound request received by the proxy and the outbound request
which will be sent by the proxy.

Since the `Director` hook is fundamentally unsafe, we are now deprecating it.
134 changes: 65 additions & 69 deletions lib/wasm/wasm_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,75 +11,71 @@
return err;
};

if (!globalThis.fs) {
let outputBuf = "";
globalThis.fs = {
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused
writeSync(fd, buf) {
outputBuf += decoder.decode(buf);
const nl = outputBuf.lastIndexOf("\n");
if (nl != -1) {
console.log(outputBuf.substring(0, nl));
outputBuf = outputBuf.substring(nl + 1);
}
return buf.length;
},
write(fd, buf, offset, length, position, callback) {
if (offset !== 0 || length !== buf.length || position !== null) {
callback(enosys());
return;
}
const n = this.writeSync(fd, buf);
callback(null, n);
},
chmod(path, mode, callback) { callback(enosys()); },
chown(path, uid, gid, callback) { callback(enosys()); },
close(fd, callback) { callback(enosys()); },
fchmod(fd, mode, callback) { callback(enosys()); },
fchown(fd, uid, gid, callback) { callback(enosys()); },
fstat(fd, callback) { callback(enosys()); },
fsync(fd, callback) { callback(null); },
ftruncate(fd, length, callback) { callback(enosys()); },
lchown(path, uid, gid, callback) { callback(enosys()); },
link(path, link, callback) { callback(enosys()); },
lstat(path, callback) { callback(enosys()); },
mkdir(path, perm, callback) { callback(enosys()); },
open(path, flags, mode, callback) { callback(enosys()); },
read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
readdir(path, callback) { callback(enosys()); },
readlink(path, callback) { callback(enosys()); },
rename(from, to, callback) { callback(enosys()); },
rmdir(path, callback) { callback(enosys()); },
stat(path, callback) { callback(enosys()); },
symlink(path, link, callback) { callback(enosys()); },
truncate(path, length, callback) { callback(enosys()); },
unlink(path, callback) { callback(enosys()); },
utimes(path, atime, mtime, callback) { callback(enosys()); },
};
}
// Use local variables instead of polluting the global namespace.
// These will be captured by closures in the importObject.
let outputBuf = "";
const fs = globalThis.fs || {
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused
writeSync(fd, buf) {
outputBuf += decoder.decode(buf);
const nl = outputBuf.lastIndexOf("\n");
if (nl != -1) {
console.log(outputBuf.substring(0, nl));
outputBuf = outputBuf.substring(nl + 1);
}
return buf.length;
},
write(fd, buf, offset, length, position, callback) {
if (offset !== 0 || length !== buf.length || position !== null) {
callback(enosys());
return;
}
const n = this.writeSync(fd, buf);
callback(null, n);
},
chmod(path, mode, callback) { callback(enosys()); },
chown(path, uid, gid, callback) { callback(enosys()); },
close(fd, callback) { callback(enosys()); },
fchmod(fd, mode, callback) { callback(enosys()); },
fchown(fd, uid, gid, callback) { callback(enosys()); },
fstat(fd, callback) { callback(enosys()); },
fsync(fd, callback) { callback(null); },
ftruncate(fd, length, callback) { callback(enosys()); },
lchown(path, uid, gid, callback) { callback(enosys()); },
link(path, link, callback) { callback(enosys()); },
lstat(path, callback) { callback(enosys()); },
mkdir(path, perm, callback) { callback(enosys()); },
open(path, flags, mode, callback) { callback(enosys()); },
read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
readdir(path, callback) { callback(enosys()); },
readlink(path, callback) { callback(enosys()); },
rename(from, to, callback) { callback(enosys()); },
rmdir(path, callback) { callback(enosys()); },
stat(path, callback) { callback(enosys()); },
symlink(path, link, callback) { callback(enosys()); },
truncate(path, length, callback) { callback(enosys()); },
unlink(path, callback) { callback(enosys()); },
utimes(path, atime, mtime, callback) { callback(enosys()); },
};

if (!globalThis.process) {
globalThis.process = {
getuid() { return -1; },
getgid() { return -1; },
geteuid() { return -1; },
getegid() { return -1; },
getgroups() { throw enosys(); },
pid: -1,
ppid: -1,
umask() { throw enosys(); },
cwd() { throw enosys(); },
chdir() { throw enosys(); },
}
}
const process = globalThis.process || {
getuid() { return -1; },
getgid() { return -1; },
geteuid() { return -1; },
getegid() { return -1; },
getgroups() { throw enosys(); },
pid: -1,
ppid: -1,
umask() { throw enosys(); },
cwd() { throw enosys(); },
chdir() { throw enosys(); },
};

if (!globalThis.path) {
globalThis.path = {
resolve(...pathSegments) {
return pathSegments.join("/");
}
const path = globalThis.path || {
resolve(...pathSegments) {
return pathSegments.join("/");
}
}
};

if (!globalThis.crypto) {
throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");
Expand Down Expand Up @@ -221,7 +217,7 @@
return this._inst.exports.testExport(a, b);
}

const timeOrigin = Date.now() - performance.now();
const timeOrigin = Date.now() - globalThis.performance.now();
this.importObject = {
_gotest: {
add: (a, b) => a + b,
Expand Down Expand Up @@ -264,7 +260,7 @@
// func nanotime1() int64
"runtime.nanotime1": (sp) => {
sp >>>= 0;
setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
setInt64(sp + 8, (timeOrigin + globalThis.performance.now()) * 1000000);
},

// func walltime() (sec int64, nsec int32)
Expand Down Expand Up @@ -306,7 +302,7 @@
// func getRandomData(r []byte)
"runtime.getRandomData": (sp) => {
sp >>>= 0;
crypto.getRandomValues(loadSlice(sp + 8));
globalThis.crypto.getRandomValues(loadSlice(sp + 8));
},

// func finalizeRef(v ref)
Expand Down
75 changes: 31 additions & 44 deletions src/cmd/cgo/internal/testcshared/cshared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bufio"
"bytes"
"cmd/cgo/internal/cgotest"
"cmp"
"debug/elf"
"debug/pe"
"encoding/binary"
Expand Down Expand Up @@ -272,7 +273,7 @@ func createHeaders() error {
// which results in the linkers output implib getting overwritten at each step. So instead build the
// import library the traditional way, using a def file.
err = os.WriteFile("libgo.def",
[]byte("LIBRARY libgo.dll\nEXPORTS\n\tDidInitRun\n\tDidMainRun\n\tDivu\n\tFromPkg\n\t_cgo_dummy_export\n"),
[]byte("LIBRARY libgo.dll\nEXPORTS\n\tDidInitRun\n\tDidMainRun\n\tDivu\n\tFromPkg\n"),
0644)
if err != nil {
return fmt.Errorf("unable to write def file: %v", err)
Expand Down Expand Up @@ -375,9 +376,23 @@ func TestExportedSymbols(t *testing.T) {
}
}

func checkNumberOfExportedFunctionsWindows(t *testing.T, prog string, exportedFunctions int, wantAll bool) {
func checkNumberOfExportedSymbolsWindows(t *testing.T, exportedSymbols int, wantAll bool) {
t.Parallel()
tmpdir := t.TempDir()

prog := `
package main
import "C"
func main() {}
`

for i := range exportedSymbols {
prog += fmt.Sprintf(`
//export GoFunc%d
func GoFunc%d() {}
`, i, i)
}

srcfile := filepath.Join(tmpdir, "test.go")
objfile := filepath.Join(tmpdir, "test.dll")
if err := os.WriteFile(srcfile, []byte(prog), 0666); err != nil {
Expand Down Expand Up @@ -443,18 +458,19 @@ func checkNumberOfExportedFunctionsWindows(t *testing.T, prog string, exportedFu
t.Fatalf("binary.Read failed: %v", err)
}

// Only the two exported functions and _cgo_dummy_export should be exported.
exportedSymbols = cmp.Or(exportedSymbols, 1) // _cgo_stub_export is exported if there are no other symbols exported

// NumberOfNames is the number of functions exported with a unique name.
// NumberOfFunctions can be higher than that because it also counts
// functions exported only by ordinal, a unique number asigned by the linker,
// and linkers might add an unknown number of their own ordinal-only functions.
if wantAll {
if e.NumberOfNames <= uint32(exportedFunctions) {
t.Errorf("got %d exported names, want > %d", e.NumberOfNames, exportedFunctions)
if e.NumberOfNames <= uint32(exportedSymbols) {
t.Errorf("got %d exported names, want > %d", e.NumberOfNames, exportedSymbols)
}
} else {
if e.NumberOfNames > uint32(exportedFunctions) {
t.Errorf("got %d exported names, want <= %d", e.NumberOfNames, exportedFunctions)
if e.NumberOfNames != uint32(exportedSymbols) {
t.Errorf("got %d exported names, want %d", e.NumberOfNames, exportedSymbols)
}
}
}
Expand All @@ -470,43 +486,14 @@ func TestNumberOfExportedFunctions(t *testing.T) {

t.Parallel()

const prog0 = `
package main

import "C"

func main() {
}
`

const prog2 = `
package main

import "C"

//export GoFunc
func GoFunc() {
println(42)
}

//export GoFunc2
func GoFunc2() {
println(24)
}

func main() {
}
`
// All programs export _cgo_dummy_export, so add 1 to the expected counts.
t.Run("OnlyExported/0", func(t *testing.T) {
checkNumberOfExportedFunctionsWindows(t, prog0, 0+1, false)
})
t.Run("OnlyExported/2", func(t *testing.T) {
checkNumberOfExportedFunctionsWindows(t, prog2, 2+1, false)
})
t.Run("All", func(t *testing.T) {
checkNumberOfExportedFunctionsWindows(t, prog2, 2+1, true)
})
for i := range 3 {
t.Run(fmt.Sprintf("OnlyExported/%d", i), func(t *testing.T) {
checkNumberOfExportedSymbolsWindows(t, i, false)
})
t.Run(fmt.Sprintf("All/%d", i), func(t *testing.T) {
checkNumberOfExportedSymbolsWindows(t, i, true)
})
}
}

// test1: shared library can be dynamically loaded and exported symbols are accessible.
Expand Down
Loading