mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user