gobyexample/examples/environment-variables/environment-variables.sh
Andreas Sommer 1b4dac72d3
Mention that environment variable set by program is also listed by os.Environ() (#436)
Co-authored-by: Andreas Sommer <andreas.sommer@ppro.com>
2022-08-22 05:59:10 -07:00

22 lines
427 B
Bash

# Running the program shows that we pick up the value
# for `FOO` that we set in the program, but that
# `BAR` is empty.
$ go run environment-variables.go
FOO: 1
BAR:
# The list of keys in the environment will depend on your
# particular machine.
TERM_PROGRAM
PATH
SHELL
...
FOO
# If we set `BAR` in the environment first, the running
# program picks that value up.
$ BAR=2 go run environment-variables.go
FOO: 1
BAR: 2
...