LinuxCommandLibrary

go-env

print and manage Go environment variables

TLDR

Print all Go environment variables

$ go env
copy
Print specific variable
$ go env GOPATH
copy
Print multiple variables
$ go env GOROOT GOPATH GOBIN
copy
Set a variable persistently
$ go env -w GOBIN=[/path/to/bin]
copy
Unset a variable
$ go env -u GOBIN
copy
Print as JSON
$ go env -json
copy

SYNOPSIS

go env [-json] [-u var] [-w var=value] [var ...]

DESCRIPTION

go env prints Go environment information. Without arguments, it prints all known environment variables. With arguments, it prints the values of the named variables. The -w flag writes values to the go/env file, making them persistent across sessions. The -u flag removes variables from go/env.

PARAMETERS

-json

Print environment in JSON format.
-w var=value
Set variable persistently in go/env file.
-u var
Unset variable from go/env file.

CONFIGURATION

$HOME/.config/go/env

Persistent Go environment variable file managed by go env -w.

CAVEATS

Variables set with -w take precedence over shell environment variables. The go/env file is typically located at $HOME/.config/go/env.

SEE ALSO

go(1), go-build(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community