我继承了一个构建脚本,该脚本构建一个docker镜像并使用hashicorp/levant库进行部署。在一年左右的时间里,我们一直在运行go get github.com/jrasell/levant来获取levant库。在过去的几天里,repo URL被合并到Hashicorp的组织下,我们已经更改了我们的脚本,以拉入go get github.com/hashicorp/levant。但无论哪种方式,我们都会得到这个多赋值错误。这是什么意思,'go‘不就是简单地拉出git repo吗?
../go/src/github.com/hashicorp/levant/template/render.go:28:11: cannot assign
*"github.com/hashicorp/nomad/vendor/github.com/hashicorp/nomad/api".Job to job
(type *"github.com/hashicorp/nomad/api".Job) in multiple assignment发布于 2020-08-22 13:45:37
首先,go get使用的是包,而不是存储库。
除了拉取它们之外,go get还会编译和安装它们,这里是错误弹出的时候。
更多信息请点击此处:
https://nanxiao.gitbooks.io/golang-101-hacks/content/posts/go-get-command.html
发布于 2020-08-22 19:36:01
我建议您使用。
hashicorp/levant确实有go.{mod,sum}文件,因此您应该忘记使用go get方法。
更好的做法是进行克隆并遵循go模块的方式,即
git clone git@github.com:hashicorp/levant.git
go test ./...
go build ./...这些步骤不仅会克隆你的repo,还会带来构建/测试包所需的依赖包。
注意:您应该安装了Go v1.11+
https://stackoverflow.com/questions/63531365
复制相似问题