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.
Этот коммит содержится в:
Ayke van Laethem 2023-02-02 18:47:37 +01:00 коммит произвёл Ayke
родитель 47ca1c037b
коммит 7fe996e7ba
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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
}