1).源代碼安裝go語言
Go的工具鏈採用C語言編寫,要構建它,你須要安裝一個C編譯器;
sudo apt-get install build-essential
Go使用Mercurial進行版本管理,首先你必須安裝了Mercurial,對於 Ubuntu/Debian 系統先安裝easy_install;
sudo apt-get install mercurial
或者執行
sudo apt-get install python-setuptools python-dev
sudo easy_install mercurial
獲取代碼;hg clone -r release https://go.googlecode.com/hg/ $HOME/go
安裝Go:
cd $GOROOT/src
./all.bash
2).設置環境變量,在/etc/profile文件同添加如下內容
export GOROOT=$HOME/go
export GOBIN=$GOROOT/bin
export GOARCH=386
export GOOS=linux
export PATH=$PATH:$GOBIN
export GOPATH=$HOME/workspace
GOPATH設置工做空間,容許多個目錄,當有多個目錄時,用分隔符分隔,當有多個GOPATH時,默認會將go get的內容放在第一個目錄下;python
$GOPATH 目錄約定有三個子目錄:
src 存放源代碼(好比:.go .c .h .s等)
pkg 編譯後生成的文件(好比:.a)
bin 編譯後生成的可執行文件(爲了方便,能夠把此目錄加入到 $PATH 變量中)
應用剛剛配置的環境變量:source /etc/profile
3).查看go是不是release版
hg identify
更新go到新版本
cd $GOROOT
hg pull
hg update release
./all.bash
4).瀏覽本地doc
在命令行執行godoc -http=:8080,在瀏覽器地址輸入:http://127.0.0.1:8080,便可進入doc界面
5).搭建基於瀏覽器的交互式Go編程指南-gotour
5.1).安裝Go語言英文教程: sudo go get code.google.com/p/go-tour/gotour
5.2).安裝Go語言中文教程: sudo go get bitbucket.org/mikespook/go-tour-zh/gotour
在命令行執行gotour,在瀏覽器地址輸入:http://127.0.0.1:3999,便可進入教程的學習界面。linux