Skip to content

Instantly share code, notes, and snippets.

@andyneff
Last active October 27, 2020 17:43
Show Gist options
  • Save andyneff/9e02194ee5ab4d5edcc88f332ae4be0e to your computer and use it in GitHub Desktop.
Save andyneff/9e02194ee5ab4d5edcc88f332ae4be0e to your computer and use it in GitHub Desktop.
Simple program to print the environment variable names in order (apparently there is an order)
package main
// docker run -it --rm -v `pwd`:/src -w /src golang go build print_env.go
import (
"fmt"
"os"
"strings"
)
func main() {
environment := os.Environ()
for i, env := range environment {
e := strings.SplitN(env, "=", 2)
fmt.Printf("% 3d) %s\n", i, e[0])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment