I can't for the life of me figure out why this is doing this. Another guy claims this works for him and that I have an environment issue. Yet every other dozen projects are working fine for me.
So just for the fun of it I started out with a completely pristine go environment. (rm -rf ~/go)
There is no go.mod/go.sum file. No other repos. No extraneous files or any kind laying around. Absolutely nothing in my go path other than my cloned repo.
I clone my repo and then with go modules enabled, "go get k8s.io/code-generator" and I get this error every time:
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
So then I repeat the above test this time with a go.mod file specifying the k8s.io/code-generator version this requires (1.13.1). Same error.
Anyone have any idea what the deal is here? My suspicion is this is a macOS related issue or something.
The one and only source file for the k8s.io/code-generator
package has a build constraint specifying +build tools
.
The go get
command “resolves and adds dependencies to the current development module and then builds and installs them.”
Since the only source file for the package you have requested does not apply to your configuration (or, indeed, to most configurations), you should instead request that the go
command stop after downloading the module, by passing the -d
flag to the command:
$ 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
With versions of the go
command before 1.13
, you may need to also pass the -m
flag to indicate that the path should be interpreted as a module rather than a package.
See also https://golang.org/issue/33526.