下载(切记不要用brew,brew会莫名的多次失败)
下载go的地址:https://golang.google.cn/dl/
下载后双击安装pkg包就进入自动安装了
安装完毕,查看版本go version
查看配置 go env
开始下载gin框架
go get -u github.com/gin-gonic/gin
go run main.go提示当前目录找不到go.mod
创建一个go模块,用go mod init + 包的名字
但是gin框架下载总是报错,下载不成功,需要设置代理,首先开启go module支持
修改env配置
go env -w GO111MODULE=auto
go env -w GOPROXY=https://goproxy.cn,direct
下载完启动项目报错
下载库依赖(报错未找到的包都要重新下载一遍)
git clone https://github.com/protocolbuffers/protobuf-go.git
git clone https://github.com/golang/tools.git
git clone https://github.com/golang/crypto.git
git clone https://github.com/go-playground/locales.git
git clone https://github.com/golang/net.git
git clone https://github.com/golang/text.git
git clone https://github.com/leodido/go-urn.git
git clone https://github.com/pelletier/go-toml.git
着重讲解sse和sys下载问题
一.sse问题
cd /Users/macuser/go/src/github.com/gin-contrib
如果遇到上图问题记得首先切换目录,然后再下载
cd /Users/macuser/go/src/golang.org/x
下载成功后,在mov迁移到指定目录下即可
mv /Users/macuser/go/src/golang.org/x /Users/macuser/go/src/github.com/gin-contrib
二.sys问题
cd /Users/macuser/go/src/golang.org/x
git clone https://github.com/golang/sys.git
最后进入项目
成功运行并输出浏览器