使用 go mod 时如何解决“不明确的导入”?
时间:2024-04-14
浏览:312
作者:佚名
知识点掌握了,还需要不断练习才能熟练运用。下面golang学习网给大家带来一个Golang开发实战,手把手教大家学习《使用 go mod 时如何解决“不明确的导入”?》,在实现功能的过程中也带大家重新温习相关知识点,温故而知新,回头看看说不定又有不一样的感悟!
问题内容
我正在尝试在我的 windows 计算机上运行 [email protected]。
我做什么:
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\[email protected]\cmd\geth)
我认为这是因为 cmd/geth 存在于 $gopath 和 $pwd 中。如何解决才能成功运行?
ps:我希望它使用 $pwd,以便我可以更改它。
解决方案
如果你想 geth,就这样做。我就是这么做的。
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
理论要掌握,实操不能落!以上关于《使用 go mod 时如何解决“不明确的导入”?》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.20
11.20
11.20
11.20
热门专题
