Skip to content

alex-held/expand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to expand 👋

Twitter: 0_alexheld

Go_Version Go Reference

Expands variables recursivly using a dependency graph algorithm

Install

go get github.com/alex-held/expand

Usage

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
}

Run tests

go test -v ./...

Author

👤 Alexander Held

Show your support

Give a ⭐️ if this project helped you!