方式一:yum安装(最简单)
| rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install golang |
方式二:源码安装:
|
wgethttp://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
tar-xvfgo1.2.linux-amd64.tar.gz
sudocp-rgo/usr/local/go
vi/etc/profile
exportGOROOT=/usr/local/go
exportPATH=$PATH:$GOROOT/bin
source/etc/profile
|
方式三:类似源码安装
| 1. $ sudo yum install mercurial 2. $ hg clone -u release https://go.googlecode.com/hg/ golang 3. To build the Go distribution, run $ cd go/src $ ./all.bash 4. If all goes well, it will finish by printing output like: ALL TESTS PASSED---Installed Go for linux/amd64 in /home/you/go.Installed commands in /home/you/go/bin.*** You need to add /home/you/go/bin to your $PATH. *** |
安装完毕之后看看状态:
|
$goversion
goversiongo1.2linux/amd64
|
测试文件
|
cathello.go
packagemain
import"fmt"
funcmain()
{
fmt.Printf("what's
up, sudops.com\n")
}
|
# go env 查看详细信息
GOARCH="686"
GOBIN="/usr/lib/golang/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -fmessage-length=0"
CXX="g++"
CGO_ENABLED="0"
有疑问加站长微信联系(非本文作者)