Last active
October 22, 2015 06:46
-
-
Save doodyparizada/825aface844f61679dee to your computer and use it in GitHub Desktop.
expand environment variables from given stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = "$GOPATH" | |
b = "$LANG" | |
c = "$NO_SUCH_ENVAR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cat config.cfg | go run main.go | |
a = "/Users/doody/Workspace/gopath" | |
b = "en_US" | |
c = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
) | |
func main() { | |
b, _ := ioutil.ReadAll(os.Stdin) | |
fmt.Print(os.ExpandEnv(string(b))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@doodyparizada does this support all the go template language spec? i need conditional support, etc.