去mod下载抱怨构建约束

时间:2019-08-13 23:08:59

标签: kubernetes go-modules client-go

我无法终生弄清楚为什么这样做。另一个人声称这对他有效,并且我遇到了环境问题。然而,每隔十二个项目对我来说都很好。

所以只是出于乐趣,我从一个完全原始的环境开始。 (rm -rf〜/ go)

没有go.mod / go.sum文件。没有其他回购。没有多余的文件或任何种类的文件。除了克隆的存储库外,绝对没有其他东西。

我克隆我的仓库,然后启用go模块,“ go get k8s.io/code-generator”,每次都会出现此错误:

package k8s.io/code-generator: build constraints exclude all Go files in /Users/me/go/pkg/mod/k8s.io/code-generator@v0.0.0-20190813220511-4e023f69fd57

因此,我这次用一个go.mod文件重复上述测试,该文件指定了所需的k8s.io/code-generator版本(1.13.1)。同样的错误。

有人知道这笔交易是什么吗?我怀疑这是与macOS相关的问题。

1 个答案:

答案 0 :(得分:0)

k8s.io/code-generator包的唯一的源文件具有一个build constraint,它指定了+build tools

go get命令“ resolves and adds dependencies to the current development module and then builds and installs them.

由于您请求的软件包的唯一源文件不适用于您的配置(或者实际上不适用于大多数配置),因此您应该请求go命令在下载模块后停止,方法是传递命令的-d标志:


$ GO111MODULE=on go1.13beta1 get k8s.io/code-generator
go: finding k8s.io/code-generator latest
can't load package: package k8s.io/code-generator: build constraints exclude all Go files in /tmp/tmp.qZqEJeHXeb/_gopath/pkg/mod/k8s.io/code-generator@v0.0.0-20190814140513-6483f25b1faf

$ GO111MODULE=on go1.13beta1 get -d k8s.io/code-generator
go: finding k8s.io/code-generator latest

go之前的1.13命令版本中,您可能还需要传递-m标志,以指示该路径应解释为模块而不是程序包。 / p>

另请参阅https://golang.org/issue/33526