Golang environments: Difference between revisions
From wikinotes
Line 23: | Line 23: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
GOPATH= | GOPATH= | ||
GOBIN= | GOBIN=~/go/bin # where go installed executables should go | ||
GOPRIVATE=*.corp.example.com,rsc.io/private # packages that should not be indexed publicly | GOPRIVATE=*.corp.example.com,rsc.io/private # packages that should not be indexed publicly |
Revision as of 02:54, 19 June 2022
Documentation
environment variables https://pkg.go.dev/cmd/go#hdr-Environment_variables
Locations
~/.config/go/env
'go env' set environment variables
Environment Variables
A small subset of useful environment variables.
GOPATH= GOBIN=~/go/bin # where go installed executables should go GOPRIVATE=*.corp.example.com,rsc.io/private # packages that should not be indexed publicly GOPROXY=
Go Env
go env
lets you set/persist go environment variables.
They will be loaded in new shells automatically.go env -w GOBIN=/foo/bar/bin # set default envvar val within environment go env -u GOBIN # unset environment variable set by 'go env'