MCPcopy
hub / github.com/wavetermdev/waveterm / EnvToMap

Function EnvToMap

pkg/util/envutil/envutil.go:18–31  ·  view source on GitHub ↗

env format: KEY=VALUE\0 keys cannot have '=' or '\0' in them values can have '=' but not '\0'

(envStr string)

Source from the content-addressed store, hash-verified

16// values can have '=' but not '\0'
17
18func 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
33func MapToEnv(envMap map[string]string) string {
34 var sb strings.Builder

Callers 9

GetVarCommandMethod · 0.92
GetAllVarsCommandMethod · 0.92
SetVarCommandMethod · 0.92
getEnvironmentNoPtyMethod · 0.92
getEnvironmentWithPtyMethod · 0.92
resolveEnvMapFunction · 0.92
GetEnvFunction · 0.85
SetEnvFunction · 0.85
RmEnvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected