windows: add support for syscall.runtimeSetenv

I missed this in https://github.com/tinygo-org/tinygo/pull/3391 (because
I didn't test on Windows, my fault).
This commit is contained in:
Ayke van Laethem
2023-02-02 21:07:38 +01:00
committed by Ayke
parent 7fe996e7ba
commit 1996fad075
3 changed files with 84 additions and 50 deletions
+23
View File
@@ -0,0 +1,23 @@
//go:build windows
package runtime
// Set environment variable in Windows:
//
// BOOL SetEnvironmentVariableA(
// [in] LPCSTR lpName,
// [in, optional] LPCSTR lpValue
// );
//
//export SetEnvironmentVariableA
func _SetEnvironmentVariableA(key, val *byte) bool
func setenv(key, val *byte) {
// ignore any errors
_SetEnvironmentVariableA(key, val)
}
func unsetenv(key *byte) {
// ignore any errors
_SetEnvironmentVariableA(key, nil)
}