Skip to content

Instantly share code, notes, and snippets.

@doodyparizada
Last active October 22, 2015 06:46
Show Gist options
  • Save doodyparizada/825aface844f61679dee to your computer and use it in GitHub Desktop.
Save doodyparizada/825aface844f61679dee to your computer and use it in GitHub Desktop.
expand environment variables from given stdin
a = "$GOPATH"
b = "$LANG"
c = "$NO_SUCH_ENVAR"
# cat config.cfg | go run main.go
a = "/Users/doody/Workspace/gopath"
b = "en_US"
c = ""
package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
b, _ := ioutil.ReadAll(os.Stdin)
fmt.Print(os.ExpandEnv(string(b)))
}
@oryband
Copy link

oryband commented Oct 22, 2015

@doodyparizada does this support all the go template language spec? i need conditional support, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment