翻譯自:talkonsomething
這篇文章告訴你怎麼在Ubuntu 9.10上安裝google的GO編譯器
第一步 : 安裝前的設定
—————————————————————————————————————————————
a. $GOROOT : GO的根目錄
* 在命令列下輸下以下命令
$ export GOROOT=/home/your-name/hg
—————————————————————————————————————————————
b. $GOOS : 作業系統名稱
* 在命令列下輸入
$ export GOOS=linux
—————————————————————————————————————————————
c.$GOARCH : 目標架構
* amd64 for AMD 64 bit processor
* 386 (32-bit x86) Intel 32 bit process and
* arm (32-bit ARM, an incomplete port)
Note: 基於你的硬體情況設定目標架構
* 命令列下輸入
$ export GOARCH=386
—————————————————————————————————————————————
d.$GOBIN : 指定二進位檔案產生的目錄
*建立目錄 /home/your-name/bin
* 賦完全許可權.
$ chmod 777 /home/your-name/bin
* 設定 $GOBIN 路徑
$ export GOBIN=/home/your-name/bin
* 在$PATH中設定 $GOBIN 路徑
$ export PATH=$PATH:/home/your-name/bin
* 為檢驗是否正確,請輸入下面第一行命令
$ env|grep '^GO'
應該返回形為下的參數
GOBIN=/home/your-name/bin
GOARCH=386
GOROOT=/home/your-name/hg/
GOOS=linux
設定完畢就可以開始第二步設定了。
—————————————————————————————————————————————
Step 2 : 獲得安裝包
* 如果你的系統上沒有安裝 Mercurial, 你可以用下面的命令安裝
$ sudo apt-get install mercurial
* 然後運行
$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT
—————————————————————————————————————————————
第三步 : 安裝前要確保你有以下組件 GCC,標準C庫, parser generator Bison.
$ sudo apt-get install bison gcc libc6-dev ed
—————————————————————————————————————————————
第四步 : 在命令列下運行
$ cd $GOROOT/src
如果檔案解壓包在hg目錄下,請將其複製出來
然後運行:
$./all.bash
如果不出錯誤,會顯示
--- cd ../test
N known bugs; 0 unexpected bugs