Skip to content

Commit 50f8d08

Browse files
committed
runtime: implement internal/godebug.setUpdate
This function was a stub, but it really needs to be implemented for full Go 1.20 support. Without it, the archive/zip tests will fail.
1 parent 47ca1c0 commit 50f8d08

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/runtime/env_unix.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ func syscallSetenv(key, value string) {
1111
valdata := cstring(value)
1212
// ignore any errors
1313
libc_setenv(&keydata[0], &valdata[0], 1)
14+
if key == "GODEBUG" && godebugUpdate != nil {
15+
// Starting with Go 1.20, we need to call a callback (set by
16+
// internal/godebug) to notify the GODEBUG environment variable has
17+
// changed. This is necessary to get archive/zip to pass tests.
18+
godebugUpdate(key, value)
19+
}
1420
}
1521

1622
// Update the C environment if cgo is loaded.

src/runtime/runtime.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
9696
// Unimplemented.
9797
}
9898

99+
var godebugUpdate func(string, string)
100+
99101
//go:linkname godebug_setUpdate internal/godebug.setUpdate
100102
func godebug_setUpdate(update func(string, string)) {
101-
// Unimplemented. The 'update' function needs to be called whenever the
102-
// GODEBUG environment variable changes (for example, via os.Setenv).
103+
// The 'update' function needs to be called whenever the GODEBUG environment
104+
// variable changes (for example, via os.Setenv).
105+
godebugUpdate = update
103106
}

0 commit comments

Comments
 (0)