mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-25 17:05:21 +00:00
22 lines
551 B
Go
22 lines
551 B
Go
package k6
|
|
|
|
import "strings"
|
|
|
|
// ParseEnvKeyValue splits an environment variable string into key and value.
|
|
func ParseEnvKeyValue(kv string) (string, string) {
|
|
if idx := strings.IndexRune(kv, '='); idx != -1 {
|
|
return kv[:idx], kv[idx+1:]
|
|
}
|
|
return kv, ""
|
|
}
|
|
|
|
// BuildEnvMap returns a map from raw environment values, such as returned from
|
|
// os.Environ().
|
|
func BuildEnvMap(environ []string) map[string]string {
|
|
env := make(map[string]string, len(environ))
|
|
for _, kv := range environ {
|
|
k, v := ParseEnvKeyValue(kv)
|
|
env[k] = v
|
|
}
|
|
return env
|
|
}
|