今天在搭建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
問題是解決了,就是有點慢,慢慢等吧,總比一早上就在找上述問題的答案強。
