Eval replaces ${var} in the string based on the mapping function.
(s string, mapping func(string) string)
| 4 | |
| 5 | // Eval replaces ${var} in the string based on the mapping function. |
| 6 | func Eval(s string, mapping func(string) string) (string, error) { |
| 7 | t, err := Parse(s) |
| 8 | if err != nil { |
| 9 | return s, err |
| 10 | } |
| 11 | return t.Execute(mapping) |
| 12 | } |
| 13 | |
| 14 | // EvalEnv replaces ${var} in the string according to the values of the |
| 15 | // current environment variables. References to undefined variables are |
searching dependent graphs…