MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / Marshal

Function Marshal

agent/utils/env/env.go:29–41  ·  view source on GitHub ↗
(envMap map[string]string)

Source from the content-addressed store, hash-verified

27}
28
29func Marshal(envMap map[string]string) (string, error) {
30 lines := make([]string, 0, len(envMap))
31 for k, v := range envMap {
32 if d, err := strconv.Atoi(v); err == nil && !isStartWithZero(v) {
33 lines = append(lines, fmt.Sprintf(`%s=%d`, k, d))
34 } else if shouldUseSingleQuotes(v) {
35 lines = append(lines, fmt.Sprintf(`%s='%s'`, k, v))
36 } else {
37 lines = append(lines, fmt.Sprintf(`%s="%s"`, k, escapeDoubleQuotedEnvValue(v)))
38 }
39 }
40 return strings.Join(lines, "\n"), nil
41}
42
43func WriteWithOrder(envMap map[string]string, filename string, orders []string) error {
44 content, err := MarshalWithOrder(envMap, orders)

Callers 1

WriteFunction · 0.85

Calls 3

isStartWithZeroFunction · 0.85
shouldUseSingleQuotesFunction · 0.85

Tested by

no test coverage detected