下载go
cd /home mkdir app cd app wget https://studygolang.com/dl/golang/go1.10.1.linux-amd64.tar.gz wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz tar -xvf go1.10.1.linux-amd64.tar.gz
新建GOPATH目录
mkdir /home/work
配置环境变量
vim /etc/profile export GOROOT=/home/app/go export GOPATH=/home/work export PATH=$PATH:$GOROOT/bin
使配置文件生效
source /etc/profile
查看配置是否生效
go version go env
测试
cd /home/work vi hello.go
package main import "fmt" func main() { fmt.Println("Hello, 世界") }
go run hello.go