golang安装

1.下载安装包并解压到/home/app目录:

tar -zxvf go1.6.linux-amd64.tar.gz -c /home/app/go

2.更改目录:

cd /home/app/go

mv go/ source/

mkdir /home/app/go/web/src -p

3.更改后的目录结构如下:

[root@ceshi02 ~]# ll /home/app/go

total 53932

drwxr-xr-x. 11 root root 4096 Jun 12 15:46 source

drwxr-xr-x. 5 root root 36 Jun 12 15:55 web

4.添加环境变量:

export GOROOT=/home/app/go/

export PATH=$PATH:$GOROOT/bin:/home/app/go/source/bin

export GOPATH=/home/app/go/src/

source /etc/profile

5.检查,执行以下命令,打印hello world:

cd /home/app/go/source/test

go run helloworld.go

6.检查版本:

go version

推荐阅读更多精彩内容