Add SetEnv misc util

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Itxaka
2023-03-17 14:45:04 +01:00
parent b3256fa436
commit 58ddd1c5df

View File

@@ -106,3 +106,12 @@ func ShellSTDIN(s, c string) (string, error) {
o, err := cmd.CombinedOutput()
return string(o), err
}
func SetEnv(env []string) {
for _, e := range env {
pair := strings.SplitN(e, "=", 2)
if len(pair) >= 2 {
os.Setenv(pair[0], pair[1])
}
}
}