MCPcopy Create free account
hub / github.com/celer-pkg/celer / replaceEnvVars

Method replaceEnvVars

context/expr_vars.go:63–74  ·  view source on GitHub ↗

replaceEnvVars replace env express with env value.

(content string)

Source from the content-addressed store, hash-verified

61
62// replaceEnvVars replace env express with env value.
63func (e ExprVars) replaceEnvVars(content string) string {
64 content = strings.ReplaceAll(content, "~", os.Getenv("HOME"))
65
66 reg := regexp.MustCompile(`\$ENV\{([^}]+)\}`)
67 return reg.ReplaceAllStringFunc(content, func(match string) string {
68 varName := reg.FindStringSubmatch(match)[1]
69 if value, ok := os.LookupEnv(varName); ok {
70 return value
71 }
72 return match
73 })
74}

Callers 1

ExpandMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected