一、下载网址
1.官网:golang.org
2.国内下载:studygolang.com/dl
网络异常,图片无法展示
|
下载好双击运行就可以了
二、环境变量的配置
- 切换到安装目录
cd /usr/local/go 复制代码
2.配置环境变量
lishuo@李硕的MacBook Pro:/usr/local/go $ vim ~/.bash_profile 复制代码
里面填写如下内容
source ~/.profile alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' export GOROOT=/usr/local/go #安装路径 export GOPATH=/User/lishuo/Code/golang #项目路径 export PATH=/usr/local/go/bin:$GOPATH/bin:$PATH #环境变量 复制代码
3.重新加载配置信息
lishuo@李硕的MacBook Pro:/usr/local/go [127] $ source ~/.bash_profile 复制代码
4.查看是否有版本信息
$ go version go version go1.18.1 darwin/amd64 复制代码
三、更换国内镜像下载
- 国内镜像网站:goproxy.cn/,按照步骤操作即可
lishuo@李硕的MacBook Pro:/usr/local/go $ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/lishuo/Library/Caches/go-build" GOENV="/Users/lishuo/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/User/lishuo/Code/golang/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/User/lishuo/Code/golang" GOPRIVATE="" GOPROXY="https://goproxy.io,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.18.1" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fme