runtime: handle GODEBUG on wasip2 (#5312)

* runtime: handle GODEBUG on wasip2
* Support env on more platforms to get GODEBUG working
This commit is contained in:
Jake Bailey
2026-04-18 14:15:47 -07:00
committed by GitHub
parent ddb848816f
commit bcb191c01e
7 changed files with 98 additions and 8 deletions
+26 -6
View File
@@ -28,18 +28,38 @@ func Getenv(key string) (value string, found bool) {
}
func Setenv(key, val string) (err error) {
// stub for now
return ENOSYS
if len(key) == 0 {
return EINVAL
}
for i := 0; i < len(key); i++ {
if key[i] == '=' || key[i] == 0 {
return EINVAL
}
}
for i := 0; i < len(val); i++ {
if val[i] == 0 {
return EINVAL
}
}
runtimeSetenv(key, val)
return nil
}
func Unsetenv(key string) (err error) {
// stub for now
return ENOSYS
runtimeUnsetenv(key)
return nil
}
func Clearenv() (err error) {
// stub for now
return ENOSYS
for _, s := range Environ() {
for j := 0; j < len(s); j++ {
if s[j] == '=' {
Unsetenv(s[:j])
break
}
}
}
return nil
}
func runtime_envs() []string
+2
View File
@@ -43,11 +43,13 @@ func Setenv(key, val string) (err error) {
}
}
libc_envs[key] = val
runtimeSetenv(key, val)
return nil
}
func Unsetenv(key string) (err error) {
delete(libc_envs, key)
runtimeUnsetenv(key)
return nil
}
+4
View File
@@ -176,3 +176,7 @@ type RawSockaddrInet4 struct {
type RawSockaddrInet6 struct {
// stub
}
// These two functions are provided by the runtime.
func runtimeSetenv(key, value string)
func runtimeUnsetenv(key string)