(template string, vars map[string]string)
| 196 | } |
| 197 | |
| 198 | func InterpolateVariables(template string, vars map[string]string) string { |
| 199 | r := regexp.MustCompile(`\$\{([^}]+)\}`) |
| 200 | return r.ReplaceAllStringFunc(template, func(m string) string { |
| 201 | // Extract the key from the match, which is in the form ${key} |
| 202 | key := strings.TrimSuffix(strings.TrimPrefix(m, "${"), "}") |
| 203 | if val, ok := vars[key]; ok { |
| 204 | return val |
| 205 | } |
| 206 | return m |
| 207 | }) |
| 208 | } |
| 209 | |
| 210 | func InterpolationNames(template string) []string { |
| 211 | r := regexp.MustCompile(`\$\{([^}]+)\}`) |
no outgoing calls