golang的安装

本文详细介绍了在CentOS环境下通过三种不同方式安装Golang的过程:使用yum命令进行简易安装、采用源码包手动安装及利用Mercurial克隆官方仓库后构建安装。同时还提供了测试安装是否成功的方法。

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

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

方式二:源码安装:

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

方式三:类似源码安装

$ 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. *** 

安装完毕之后看看状态:

$go version
go version go1.2 linux/amd64

测试文件

vim hello.go

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

运行:

go run hello.go
hello go

转载于:https://www.cnblogs.com/lzxianren/p/5518919.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值