使用go mod时如何解决“模糊导入”?

时间:2019-03-27 07:03:29

标签: go

我正在尝试在Windows计算机上运行go-ethereum@v1.0.0。

我做什么:

cd G:\go
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum/cmd/geth
git checkout tags/v1.0.0 -b v1.0.0
go mod init github.com/ethereum/go-ethereum/cmd/geth
go run .

我希望go mod可以帮助我安装所有模块,但遇到错误:

package github.com/ethereum/go-ethereum/cmd/geth: unknown import path "github.com/ethereum/go-ethereum/cmd/geth": ambiguous import: found github.com/ethereum/go-ethereum/cmd/geth in multiple modules:
        github.com/ethereum/go-ethereum/cmd/geth (G:\go\go-ethereum\cmd\geth)
        github.com/ethereum/go-ethereum v1.8.23 (G:\GOPATH\pkg\mod\github.com\ethereum\go-ethereum@v1.8.23\cmd\geth)

我认为这是因为cmd / geth同时存在于$ GOPATH和$ PWD中。我该如何解决才能成功运行?

PS:我希望它使用$ PWD,以便我可以对其进行更改。

1 个答案:

答案 0 :(得分:0)

如果您想得到,请执行此操作。我做到了。

cd $GOPATH/src
git clone https://github.com/ethereum/go-ethereum.git
cd $GOPATH/src/github.com/ethereum/go-ethereum
git checkout tags/v1.0.0 -b v1.0.0
go install github.com/ethereum/go-ethereum/cmd/geth
ls $GOPATH/bin/geth