- Hello World in Go
- Semicolons in Go
- Short Declarations
(Using the:=
operator) - iota in Go
- Enumerations in Go
What are Go Runtime Environment Variables?
The go env
command prints the value of environment variables used by the Go tools. These variables are used to configure the behavior of the Go tools and the Go runtime. These runtime environment variables are used to control the behavior of the Go runtime, and the Go tools. The Go tools include the go
command, the gofmt
command, and the godoc
command. The Go runtime is the part of the Go toolchain that executes Go programs.
Manipulating Go runtime environment variables:
- Show all environment variables
go env
- Show a specific environment variable
go env [GOPATH]
- Set an environment variable to a value
go env -w [GOBIN]=[path/to/directory]
- Reset an environment variable's value
go env -u [GOBIN]
- Get help on a specific subcommand
# tells you about the -w flag go help env -w
- Get more help
# tells you about the go env command go help env
# tells you about all the Go environment variables go help environment
Read further at:
- A whirlwind tour of Go runtime environment variables - Dave Cheney
- Go your own way - Sourav Choudhary
- Go environment variables explained in 5 mins - GolangDojo (YT)
- Golang Environment and Golang Command - Wahyu Eko Hadi Saputro
- Go runtime environment variables - Golang Docs
- The Go's official env.go file
The following environment variables ($name
or %name%
, depending on the host operating system) control the run-time behavior of Go programs. The meanings and use may change from release to release.
This arrangement lists the Go runtime environment variables in alphabetical order for easier reference and lookup.
- GOCACHE and GOTMPDIR
- GOGC
- GO111MODULE
- GOARCH and GOOS
- GOBIN
- GOENV
- GOFLAGS
- GOMAXPROCS
- GOMOD
- GOPATH
- GOPROXY
- GOROOT
- GOTRACEBACK
- GODEBUG
- Variable Types
- Operations on variables
(You might need to study Operators in case of any anomalies) - Type Conversions
- Type Inference
- Type Inference
(Read further at https://go.dev/blog/type-inference) - Variable Naming Conventions
- Variable Scopes
- Variable Shadowing
- Constants in Go
(Read further at https://golangbyexample.com/constant-golang/) - Abbreviated Variable Declarations
Tip: Create a playground
directory in the root
directory and then test these examples yourself.