CentOS7安装Go运行和开发环境
下载并解压 [root soft]# wget -c https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz(可用迅雷下载)
[root soft]# tar -C /usr/local/ -zxvf go1.8.3.linux-amd64.tar.gz不用 make && make install 来安装了, 开箱即用
添加系统环境变量 [root soft]# vi /etc/profile.d/go.sh export PATH=$PATH:/usr/local/go/bin :wq!保存退出 [root soft]# source /etc/profile.d/go.sh 测试:[root@localhost codis]# goGo is a tool for managing Go source code.Usage: go command [arguments]The commands are: build compile packages and dependencies clean remove object files doc show documentation for package or symbol env print Go environment information bug start a bug report fix run go tool fix on packages fmt run gofmt on package sources generate generate Go files by processing source get download and install packages and dependencies install compile and install packages and dependencies list list packages run compile and run Go program test test packages tool run specified go tool version print Go version vet run go tool vet on packagesUse "go help [command]" for more information about a command.Additional help topics: c calling between Go and C buildmode description of build modes filetype file types gopath GOPATH environment variable environment environment variables importpath import path syntax packages description of package lists testflag description of testing flags testfunc description of testing functionsUse "go help [topic]" for more information about that topic.
添加GOPATH目录 [root ~]# mkdir -p ~/go 添加这个目录路径作为GOPATH [root@localhost ~]# vi /etc/profile.d/gopath.sh export GOPATH=/root/go
保存退出:wq!
[root@localhost ~]# source /etc/profile.d/gopath.sh验证GOPATH环境变量是否添加成功
[root@localhost ~]# echo $GOPATH
/root/dev/go运算GO环境测试
创建测试文件 hello_world.go [root@localhost ~]# vi ~/go/hello_world.go 编辑文件package mainimport ( "fmt")func main() { fmt.Println( "Hello world!" )}
运算测试文件 hello_world.go
[root@localhost ~]# go run ~/dev/go/hello_world.goHello world!