CentOS下go 安裝

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。 go 語言源碼安裝依賴 ,gcc ,make glibc庫,等,上述工具安裝省略,另外,其原始碼更新採用的是mercurial 工具,安裝前先安裝mercureal : 1.mercurial安裝使用yum install mercurial

2.設定環境變數在.bash_profile中
#go set
export GOROOT=/usr/local/go
export GOOS=linux
export GOARCH=386
export GOBIN=$GOROOT/bin

PATH=$PATH:$GOBIN
export PATH
alias cdg="cd /project/go"

2.下載go安裝包:
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
cd $GOROOT/src && ./all.bash


3.運行go  看是否能找到命令
4.編寫demo程式驗證下:1.編寫demo程式:

demo.go     package main  import "fmt"      func main() {      fmt.Printf("Let's go\n")  }  

 


1>編譯運行:
  go run demo.go
  
2>單步編譯,單步串連
  [root@andes.com /project/go]#ls
  demo.go
  [root@andes.com /project/go]#go tool 8g demo.go 
  [root@andes.com /project/go]#ls
  demo.8  demo.go
  [root@andes.com /project/go]#go tool 8l demo.8   
  [root@andes.com /project/go]#ls
  8.out  demo.8  demo.go
  [root@andes.com /project/go]#8.out
  Let's go
5.添加vim 對go支援
將/go/misc/vim 下相關檔案拷貝到$HOME/.vimrc  

聯繫我們

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