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/go export 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 main import "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/hello hello, world 到這裏,你的go就算安裝好了。