MCPcopy
hub / github.com/bootdotdev/bootdev / InterpolateVariables

Function InterpolateVariables

checks/http.go:198–208  ·  view source on GitHub ↗
(template string, vars map[string]string)

Source from the content-addressed store, hash-verified

196}
197
198func 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
210func InterpolationNames(template string) []string {
211 r := regexp.MustCompile(`\$\{([^}]+)\}`)

Callers 10

printHTTPRequestResultFunction · 0.92
runHTTPRequestFunction · 0.85
prettyPrintHTTPTestFunction · 0.85
prettyPrintStdoutJqTestFunction · 0.85
formatJqExpectedValueFunction · 0.85
runStdoutJqQueryFunction · 0.85
CLIChecksFunction · 0.85
runCLICommandFunction · 0.85
prettyPrintCLICommandFunction · 0.85
TestInterpolateVariablesFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestInterpolateVariablesFunction · 0.68