一 需要设置项
1、有4个环境变量需要设置:GOROOT、GOPATH、GOBIN,以及PATH
2、需要设置到某一个profile文件中(~/.bash_profile)或(/etc/profile)
二 环境变量设置
1、GOROOT:该环境变量的值为Go语言的当前安装目录,执行:
[root@localhost go]# export GOROOT=/usr/local/go
2、GOPATH:该环境变量的值为Go语言工作区的集合,执行:
[root@localhost go]# export GOPATH=~/golib:~/goproject: ~/ goc2p
3、GOBIN:该环境变量的值是存放Go程序的可执行文件的目录,执行:
[root@localhost go]# export GOBIN=~/gobin
4、PATH:为了方便使用Go语言命令和Go程序的可执行文件,需要追加其值,执行:
[root@localhost go]# export PATH=$PATH:$GOROOT/bin:$GOBIN
以上四条语句为:
[root@localhost go]# export GOROOT=/usr/local/go
[root@localhost go]# export GOPATH=~/golib:~/goproject:~/goc2p
[root@localhost go]# export GOBIN=~/gobin
[root@localhost go]# export PATH=$PATH:$GOROOT/bin:$GOBIN
三 校验设置结果
在