golang安装gin框架报错 cannot find module providing ……working directory is not part of a module

 

  1. 接下来安装gin,框架文档介绍:go get -u github.com/gin-gonic/gin

  2. 这时候开始遇到问题了,常遇问题资源加载不了,解决方法是使用代理(这块有个 go env 的命令,可以查看当前配置),在cmd中运行:

go env -w GO111MODULE=on

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

设置后运行:
go get -u github.com/gin-gonic/gin

 golang安装gin框架报错 cannot find module providing package github.com/gin-gonic/gin: working directory is not part of a module

执行下列命令:

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

 

上一篇:如何理解python中的类?


下一篇:Python Crash Course读书笔记 - 第4章:WORKING WITH LISTS