cannot find module providing package github.com/× working directory is not part of a module

今天在搭建fabric的过程中遇到一个问题,记录一下

 root@zitao /home/hong/Desktop/gowork/src/github.com/hyperledger/fabric release-2.0  make all                            
Building build/bin/orderer
GOBIN=/home/hong/Desktop/gowork/src/github.com/hyperledger/fabric/build/bin go install -tags "" -ldflags "-X github.com/hyperledger/fabric/common/Metadata.Version=2.0.2 -X github.com/hyperledger/fabric/common/Metadata.CommitSHA=72c79a222 -X github.com/hyperledger/fabric/common/Metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/Metadata.DockerNamespace=hyperledger" github.com/hyperledger/fabric/cmd/orderer
cannot find module providing package github.com/hyperledger/fabric/cmd/orderer: working directory is not part of a module
make: *** [Makefile:200:build/bin/orderer] 错误 1

google了好久,一直没看出是哪的问题,有的说是没有go.mod

使用命令go mod init

亲测,这个无效。

最后找到一篇 https://studygolang.com/articles/28573

这个上面说,可能是在使用 goproxy 的时候,开启了 GO111MODULE,导致包管理非官方所说的在 $GOPATH\src\,而是去了 $GOPATH\src\pkg\目录下,此时就需要用go mod引入这些包 require github.com/gin-gonic/gin@latest ,解决import获取不了包的问题。

所以,我用了一个最笨的方法,直接将GO111MODULE关了

export GO111MODULE=off

问题是解决了,就是有点慢,慢慢等吧,总比一早上就在找上述问题的答案强。

相关文章

developer-roadmap —— 提供最全的开发者技术路线指南。前端...
一个极简的文件分享工具,无需注册且没有广告即可生成共享下...
收集 Github、Gitee优秀的开源项目,并进行归类整理。项目地...
大家好,我是 Java陈序员,我们有时会搭建一个属于自己的网站...
一个提供交互式的Web UI用于生成兼容MyBatisPlus框架的相关功...
大家好,我是 Java 陈序员。权限认证是我们日常开发绕不过的...