gin初次运行

1,473 阅读1分钟

因为防火墙的问题,gin并不一定能够运行,

哪怕挂上梯子也不行,此时我用了一个go下载代理

代理之后基本都能解决 如果还是不能用

首先设置代理

这是代理工具的网址 goproxy.io/zh/

$ go env -w GO111MODULE=on

$ go env -w GOPROXY=https://goproxy.io,direct

下载gin

$ go get -u github.com/gin-gonic/gin

下载govendor

$ go get github.com/kardianos/govendor

使用 govendor 初始化项目,并且引入 gin

$ govendor init

$ govendor fetch github.com/gin-gonic/gin@v1.3

如果还是报错的话go: inconsistent vendoring in D:\GoWork\src\go_cloud:......

执行这些操作就可以用了

$ go mod vendor

$ go build

$ go run main.go 虽然我也不知道为什么,但是这样就是可以了,应该是mod 的问题

还有个错误

需要用go mod引入这些包 require github.com/gin-gonic/gin@latest ,解决import获取不了包的问题。 $ go mod init gin

$ go mod edit -require github.com/gin-gonic/gin@latest