Linux command
go-env 命令
文本
Copy it and replace filenames, paths, or keywords as needed.
命令示例
Print all Go environment variables
go env
Print specific variable
go env GOPATH
Print multiple variables
go env GOROOT GOPATH GOBIN
Set a variable persistently
go env -w GOBIN=[/path/to/bin]
Unset a variable
go env -u GOBIN
Print as JSON
go env -json
说明
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.
参数
- -json
- Print environment in JSON format.
- -w _var_=_value_
- Set variable persistently in go/env file.
- -u _var_
- Unset variable from go/env file.
FAQ
What is the go-env command used for?
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.
How do I run a basic go-env example?
Run `go env` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -json do in go-env?
Print environment in JSON format.