Installation golang-1.18
一、Installation golang-1.18
1 下载
mkdir /opt/software && cd /opt/software
wget https://golang.google.cn/dl/go1.18.linux-amd64.tar.gz
2 解压
tar -zxvf /opt/software/go1.18.linux-amd64.tar.gz -C /opt && cd /opt/go && ll
3 配置环境变量
vi /etc/profile
### golang env config
export GO111MODULE=on
export GOROOT=/opt/go
export GOPATH=/home/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
source /etc/profile
###
go version
4 设置代理环境变量,下载golang.org依赖包无需梯子
###
go env -w GOPROXY=https://goproxy.cn,direct
go env |grep GOPROXY
5 测试
cd /home/gopath
###
cat > /home/gopath/gomain.go << EOF
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
EOF
###
go run /home/gopath/gomain.go
X、One Step Success
Y、Error message
Z、Related Links