官网 https://golang.google.cn/dl/
Linux环境:
cd /data/www wget https://golang.google.cn/dl/go1.14.7.linux-amd64.tar.gz // 解压并安装到 /usr/local tar -C /usr/local -xzf go1.14.7.linux-amd64.tar.gz mkdir golang 添加环境变量,开启go mod 包管理模式 vi /etc/profile # go安装怒路 export GOROOT=/usr/local/go # GOPATH环境变量 export GOPATH=/data/www/golang/path # 依赖包代理服务器 export GOPROXY=https://goproxy.io # 开启go mod 模式 export GO111MODULE=on export GOSUMDB=off # go可执行程序导入到系统环境变量 export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/data/www/golang/path/bin source /etc/profile go env go version mkdir -p project/demo1 cd project/demo1 vi hello.go
测试
package main import "fmt" func main(){ fmt.Println("Hello World"); }
go run hello.go
补充:
1、go在1.13版本后,默认开启了GOSUMDB=sum.golang.org,而这个网址sum.golang.org 在国内是无法访问,报错如下
go get gopkg.in/ini.v1: gopkg.in/[email protected]: verifying module: gopkg.in/[email protected]: Get "https://sum.golang.org/lookup/gopkg.in/[email protected]": dial tcp 142.251.43.17:443: con nectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to r espond.
关闭方式:go env -w GOSUMDB=off
参考:https://www.cnblogs.com/xiaoyingzhanchi/p/14410626.html
windows环境的配置
vscode支持golang
1、Go 插件
2、安装gopls
3、当右下角出现Analysis Tools Missing
的时候,点击一下,然后点击install即可。
本文转自:https://blog.csdn.net/raoxiaoya/article/details/109056864
标签:www,golang,开发,export,https,go,local,搭建 From: https://www.cnblogs.com/nizuimeiabc1/p/17314135.html