centos7 搭建go环境

下载go
#cd /home
#mkdir app
#cd app

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

# tar zxvf go1.9.linux-amd64.tar.gz

新建GOPATH目录
# mkdir /home/work
# vim /etc/profile

export GOROOT=/home/app/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/home/work
:wq保存

使其生效
#source /etc/profile

查看是否配置成功
# go version
go version go1.9.1 linux/amd64

简单测试:
# cd /home/work
# vi hello.go
package main
import "fmt"
func main() {
    fmt.Println("Hello, 世界")
}
# go run hello.go
Hello, 世界

  

posted on 2018-10-22 21:36  清明-心若淡定  阅读(320)  评论(0编辑  收藏  举报