Skip to content

Instantly share code, notes, and snippets.

@nickserv
Created March 13, 2014 00:22
Show Gist options
  • Save nickserv/9519543 to your computer and use it in GitHub Desktop.
Save nickserv/9519543 to your computer and use it in GitHub Desktop.
List all environment variables in Go
package main
import (
"os"
"fmt"
)
func main() {
for _, pair := range os.Environ() {
fmt.Println(pair)
}
}
@coolaj86
Copy link

@avnish30jn A process is "firewalled" from its parents and siblings. One process can have the same variable with a completely different value as another. A process only has access to its own envs (and the ones the parent exports). Were it not so, scripting would be... hell, in the worst way.

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