(envMap map[string]string)
| 27 | } |
| 28 | |
| 29 | func 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 | |
| 43 | func WriteWithOrder(envMap map[string]string, filename string, orders []string) error { |
| 44 | content, err := MarshalWithOrder(envMap, orders) |
no test coverage detected