ubuntu16.04安装go18

1、下载go1.8

$ sudo curl -O https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz

2、解压和配置go环境

$ tar xvf go1.6.linux-amd64.tar.gz

会生成一个go目录

$ 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

你可能感兴趣的:(ubuntu)