Linux Golang安裝
安裝版本查看,可自行選擇
https://studygolang.com/articles/13957?fr=sidebar
此次選擇
go1.14.2.linux-amd64.tar.gz Archive Linux x86-64 118MB 6272d6e940ecb71ea5636ddb5fab3933e087c1356173c61f4a803895e947ebb3
wget https://studygolang.com/dl/golang/go1.14.2.linux-amd64.tar.gz
tar -C /usr/local -zxvf go1.14.2.linux-amd64.tar.gz
// 習慣用vim,沒有的話可以用命令`sudo apt-get install vim`安裝一個
vim /etc/profile
// 在最后一行添加
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
// wq保存退出后source一下
source /etc/profile
Golang依賴包安裝
go mod init [module]
#具體看看這個
go help mod init
#檢查是否安裝成功
go version
#安裝成功后,設置環境變量
go env -w GO111MODULE=on
go env -w GOPROXY="https://mirrors.aliyun.com/goproxy/"
附上一部分go get 下載沒反應問題
可以通過ip查詢網站
https://www.ipaddress.com/ip-lookup
github.com
github.global.ssl.fastly.net 這兩個網站的ip,配置hosts綁定
windows改hosts
C:\Windows\System32\drivers\etc\hosts
linux改hosts
/etc/hosts