本文主要介绍的是windows环境配置.
访问: https://golang.org/dl/ 或 https://golang.google.cn/dl/下载安装包 windows下载msi文件即可。
安装完随便运行一段go代码,运行正常即可
package main import "fmt" func main() { fmt.Println("Hello, World!") }
go的安装路径是: D:\Go
go项目的开发路径是: E:\GoProject
D:\Go\bin;
E:\goProjects;
新增/修改GOPATH
为E:\goProjects
;
$GOPATH目录下新建三个文件夹: pkg, bin, src
# 设置goproxy.io代理 go env -w GOPROXY="https://goproxy.io" # 设置GO111MOUDLE go env -w GO111MODULE="on"
未配置代理执行go get
时, 会报以下错误
go get: module github.com/gin-gonic/gin: Get "https://proxy.golang.org/github.com/gin-gonic/gin/@v/l ist": dial tcp 172.217.160.81:443: connectex: A connection attempt failed because the connected part y did not properly respond after a period of time, or established connection failed because connecte d host has failed to respond.