ubuntu16.04安装go1.9

1. 下载

$ wget  https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz  


2、解压和配置环境

$ tar xvf  go1.9.2.linux-amd64.tar.gz
$ sudo chown -R root:root ./go
$ sudo mv go /usr/local/

$ sudo vim /etc/profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/work
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
$ sudo source /etc/profile

3、测试 go 环境

$ mkdir -p $HOME/work
$ mkdir -p work/src/github.com/user/hello
$ vim ~/work/src/github.com/user/hello/hello.go
package main
import "fmt"
func main() {
    fmt.Printf("hello, world\n")
}
$ go install github.com/user/hello
$ hello
$ which hello
Output
/home/user/work/bin/hello

你可能感兴趣的:(ubuntu16.04安装go1.9)