env format: KEY=VALUE\0 keys cannot have '=' or '\0' in them values can have '=' but not '\0'
(envStr string)
| 16 | // values can have '=' but not '\0' |
| 17 | |
| 18 | func EnvToMap(envStr string) map[string]string { |
| 19 | rtn := make(map[string]string) |
| 20 | envLines := strings.Split(envStr, "\x00") |
| 21 | for _, line := range envLines { |
| 22 | if len(line) == 0 { |
| 23 | continue |
| 24 | } |
| 25 | parts := strings.SplitN(line, "=", 2) |
| 26 | if len(parts) == 2 { |
| 27 | rtn[parts[0]] = parts[1] |
| 28 | } |
| 29 | } |
| 30 | return rtn |
| 31 | } |
| 32 | |
| 33 | func MapToEnv(envMap map[string]string) string { |
| 34 | var sb strings.Builder |
no outgoing calls
no test coverage detected