diff --git a/src/runtime/env_unix.go b/src/runtime/env_unix.go index 70716204..6fb13c56 100644 --- a/src/runtime/env_unix.go +++ b/src/runtime/env_unix.go @@ -11,6 +11,12 @@ func syscallSetenv(key, value string) { valdata := cstring(value) // ignore any errors libc_setenv(&keydata[0], &valdata[0], 1) + if key == "GODEBUG" && godebugUpdate != nil { + // Starting with Go 1.20, we need to call a callback (set by + // internal/godebug) to notify the GODEBUG environment variable has + // changed. This is necessary to get archive/zip to pass tests. + godebugUpdate(key, value) + } } // Update the C environment if cgo is loaded. diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index 1a2a0495..a9778eae 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -96,8 +96,11 @@ func SetFinalizer(obj interface{}, finalizer interface{}) { // Unimplemented. } +var godebugUpdate func(string, string) + //go:linkname godebug_setUpdate internal/godebug.setUpdate func godebug_setUpdate(update func(string, string)) { - // Unimplemented. The 'update' function needs to be called whenever the - // GODEBUG environment variable changes (for example, via os.Setenv). + // The 'update' function needs to be called whenever the GODEBUG environment + // variable changes (for example, via os.Setenv). + godebugUpdate = update }