ubuntu下golang 環境安裝步驟

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

1,環境變數設定

~$ cd 

~$ mkdir go

~$ mkdir bin

~$ sudo  gedit .bashrc

在bash檔案的最後添加如下代碼來設定目錄變數:

 

export GOROOT=$HOME/go
export GOOS=linux
export GOARCH=386
export GOBIN=$HOME/bin
儲存檔案
~$ source .bashrc
~$ sudo gedit /etc/profile
在檔案最後修改PATH,PATH尚未存在,直接添加如下語句,否則添加

export PATH=$HOME/bin:$PATH
儲存檔案
~$ source /etc/profile
執行env | grep '^GO'測試是否已經正確設定GO的環境變數

2,擷取資源

 

~$ hg clone -r release https://go.googlecode.com/hg/ $GOROOT

如果不成功,則先安裝mercurial:

~$ sudo apt-get install mercurial

3,安裝

~$ sudo apt-get install bison gcc libc6-dev ed

~$ cd $GOROOT/src

~$ ./all.bash

 

等待幾分鐘,最後它會自測出現--- cd ../test

~$ cd

~$ mkdir helloGo
~$ cd helloGo
~$ cat >hello.go <<EOF
 > package main
 > import "fmt"
 > func main() {
 > fmt.Printf("hello, world/n"
 >  }
 >  EOF
~$ 8g hello.go
~$ 8l hello.8
~$ ./8.out
hello, world

 

4,參考

1,golang官網 http://golang.org/


原文地址:http://blog.csdn.net/xinshg/article/details/5199651


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.