Expands variables recursivly using a dependency graph algorithm
🏠 Homepage
go get github.com/alex-held/expand
func main() {
vars := map[string]string{
"a": "$HOME/$b/$c",
"b": "$c/foo",
"c": "bar",
"HOME": "/home/user" // override environment variable
}
expansions, err := expand.Expand(vars)
if err != nil {
panic(err)
}
println(expansions.MustGet("a"))
// Outputs:
// /home/user/bar/foo/bar
}
go test -v ./...
👤 Alexander Held
- Website: https://alexheld.io
- Twitter: @0_alexheld
- Github: @alex-held
Give a ⭐️ if this project helped you!