在ubuntu上安裝GO

來源:互聯網
上載者:User

翻譯自: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.