package
0.0.0-20240414154438-d99ce7fa4a54
Repository: https://github.com/kshji/go.git
Documentation: pkg.go.dev
# README
Go Language - Parse OS environment variables and expand values in template
This parse_env.go read all your environment variables to the map (hash table).
And also expand variable values in string template.
Example
input := `
Hello world, my home dir is {HOME} and logname is {LOGNAME}.
My terminal type is {TERM}
`
Result is:
Hello world, my home dir is /home/myusername and logname is myusername.
My terminal type is xterm-256
// envvars map (hash table) include variable values
// regexp rule to find {XXX} strings
input := 'some text including {TERM} variables to expand like HOME:{HOME}`
r := regexp.MustCompile(`{([^}]+)}`)
result := Expand(input,r,envvars)
# Functions
No description provided by the author