golang的安装

整理了一下,网上关于golang的安装有三种方式(注明一下,我的环境为CentOS-6.x, 64bit)
方式一:yum安装(最简单)

shell
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install golang


方式二:源码安装:

```shell```
wget http://go.googlecode.com/files/go1.2.linux-amd64.tar.gz
tar -xvf go1.2.linux-amd64.tar.gz
sudo cp -r go /usr/local/go

vi /etc/profile

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

source /etc/profile

方式三:类似源码安装

shell
$ sudo yum install mercurial
$ hg clone -u release https://go.googlecode.com/hg/ golang
To build the Go distribution, run
cd go/src
./all.bash
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. ***


安装完毕之后看看状态:
```shell```
$go version
go version go1.2 linux/amd64

测试文件

vim hello.go
go
package main
import "fmt"
func main()
{
fmt.Printf("hello go\n")
}


运行:
```shell```
go run hello.go
hello go
posted @ 2016-05-23 10:10  每日懂一点  阅读(1193)  评论(0编辑  收藏  举报