這是一個建立於
的文章,其中的資訊可能已經有所發展或是發生改變。
https://golang.org/doc/install下載好後,通過FTPS,傳遞到Linux裡去,放哪裡隨便你自己,因為被牆了,所以在Windows通過旋風下載了這個玩意兒。你也可以:wget https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz//將go解壓到/opt,個人喜好罷了[root@localhost ~]# tar -C /opt -xzf ./go1.5.linux-amd64.tar.gz /*在末尾增加一下兩行,GOPATH是工作目錄,GOROOT表示指出go的根目錄位置 ps:在自訂程式的安裝位置後,需要設定這個export GOROOT=/opt/goexport PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/goTest*/[root@localhost ~]# vim /etc/profile[root@localhost ~]# source /etc/profile[root@localhost ~]# mkdir ./goTest/src/test[root@localhost test]# touch ./hello.go寫入內容到hello.go:package mainimport "fmt"func main() { fmt.Printf("hello, world\n")}[root@localhost src]# cd ..//出現這個錯誤了,叫我們設定一個.go檔案安裝後,產生的可執行二進位檔案儲存在哪個目錄,這個通過GOBIN設定地址,export GOBIN=$GOPATH/bin把這段寫到/etc/profile的後面去吧。[root@localhost src]# go install test/hello.go go install: no install location for .go files listed on command line (GOBIN not set)[root@localhost src]# source /etc/profile[root@localhost src]# go install test/hello.go [root@localhost src]# $GOBIN/hellohello, world到這裡,你的go就算安裝好了。