cannot find module providing package github.com/× working directory is not part of a module
阅读原文时间:2023年07月09日阅读:1

今天在搭建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

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

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章