golang的安裝

整理了一下,網上關於golang的安裝有三種方式(註明一下,個人環境爲CentOS-6.x, 64bit)
方式一:yum安裝(最簡單)linux

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

方式二:源碼安裝: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

方式三:相似源碼安裝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. ***

安裝完畢以後看看狀態:vim

$go version
go version go1.2 linux/amd64

測試文件bash

vim hello.go測試

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

運行:ui

go run hello.go
hello go
相關文章
相關標籤/搜索