golang环境

$ vi /etc/profile.d/golang.sh
# 将以下环境变量添加到profile最后面
export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/data/gopath
$ source /etc/profile

#!/bin/bash
wget -c https://studygolang.com/dl/golang/go1.14.3.linux-amd64.tar.gz
tar -C /usr/local -zxvf go1.14.3.linux-amd64.tar.gz

go_etc=/etc/profile.d/golang.sh
touch $go_etc

# shellcheck disable=SC2129
echo "export GO111MODULE=on" >> $go_etc
echo "export GOPROXY=https://goproxy.cn,direct" >> $go_etc
echo "export GOROOT=/usr/local/go" >> $go_etc
echo "export PATH=\$PATH:\$GOROOT/bin" >> $go_etc
echo "export GOPATH=/data/gopath" >> $go_etc
source /etc/profile
go env

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。