aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/windows/env_windows.go
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@sap.com>2022-04-01 14:08:42 +0200
committerSandro Jäckel <sandro.jaeckel@sap.com>2022-04-01 14:09:09 +0200
commitd35e5fb09bfac1fa381e4ed004ea24a6025e36f4 (patch)
treee47874ed2c6830abf4c84e9068bc187fb041b6b4 /vendor/golang.org/x/sys/windows/env_windows.go
parentcb398f58a5cb4f3e858fe60e84debde6ab58f7c8 (diff)
downloadgofu-d35e5fb09bfac1fa381e4ed004ea24a6025e36f4.tar.gz
Bump to go 1.17 and update all dependencies
Diffstat (limited to 'vendor/golang.org/x/sys/windows/env_windows.go')
-rw-r--r--vendor/golang.org/x/sys/windows/env_windows.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/vendor/golang.org/x/sys/windows/env_windows.go b/vendor/golang.org/x/sys/windows/env_windows.go
index bdc71e2..92ac05f 100644
--- a/vendor/golang.org/x/sys/windows/env_windows.go
+++ b/vendor/golang.org/x/sys/windows/env_windows.go
@@ -6,7 +6,10 @@
package windows
-import "syscall"
+import (
+ "syscall"
+ "unsafe"
+)
func Getenv(key string) (value string, found bool) {
return syscall.Getenv(key)
@@ -24,6 +27,28 @@ func Environ() []string {
return syscall.Environ()
}
+// Returns a default environment associated with the token, rather than the current
+// process. If inheritExisting is true, then this environment also inherits the
+// environment of the current process.
+func (token Token) Environ(inheritExisting bool) (env []string, err error) {
+ var block *uint16
+ err = CreateEnvironmentBlock(&block, token, inheritExisting)
+ if err != nil {
+ return nil, err
+ }
+ defer DestroyEnvironmentBlock(block)
+ blockp := uintptr(unsafe.Pointer(block))
+ for {
+ entry := UTF16PtrToString((*uint16)(unsafe.Pointer(blockp)))
+ if len(entry) == 0 {
+ break
+ }
+ env = append(env, entry)
+ blockp += 2 * (uintptr(len(entry)) + 1)
+ }
+ return env, nil
+}
+
func Unsetenv(key string) error {
return syscall.Unsetenv(key)
}