mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
os: implement and smoketest os.Unsetenv
This commit is contained in:
@@ -13,6 +13,16 @@ func syscall_setenv_c(key string, val string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Update the C environment if cgo is loaded.
|
||||
// Called from syscall.Unsetenv.
|
||||
//go:linkname syscall_unsetenv_c syscall.unsetenv_c
|
||||
func syscall_unsetenv_c(key string) {
|
||||
keydata := cstring(key)
|
||||
// ignore any errors
|
||||
libc_unsetenv(&keydata[0])
|
||||
return
|
||||
}
|
||||
|
||||
// cstring converts a Go string to a C string.
|
||||
// borrowed from syscall
|
||||
func cstring(s string) []byte {
|
||||
@@ -25,3 +35,7 @@ func cstring(s string) []byte {
|
||||
// int setenv(const char *name, const char *val, int replace);
|
||||
//export setenv
|
||||
func libc_setenv(name *byte, val *byte, replace int32) int32
|
||||
|
||||
// int unsetenv(const char *name);
|
||||
//export unsetenv
|
||||
func libc_unsetenv(name *byte) int32
|
||||
|
||||
Reference in New Issue
Block a user