<p>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.</p>

<p>So just for the fun of it I started out with a <em>completely pristine</em> go environment. (rm -rf ~/go)</p>

<p>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.</p>

<p>I clone my repo and then with go modules enabled, "go get k8s.io/code-generator" and I get this error every time:</p>

<pre><code>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
</code></pre>

<p>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.</p>

<p>Anyone have any idea what the deal is here? My suspicion is this is a macOS related issue or something.</p>

<p>The one and only source file for the <code>k8s.io/code-generator</code> package has a <a href="https://golang.org/pkg/go/build/#hdr-Build_Constraints" rel="nofollow noreferrer">build constraint</a> specifying <a href="https://github.com/kubernetes/code-generator/blob/6483f25b1faf70af19925981b3de8f01d6a53712/tools.go#L1" rel="nofollow noreferrer"><code>+build tools</code></a>.</p>

<p>The <code>go get</code> command “<a href="https://tip.golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them" rel="nofollow noreferrer">resolves and adds dependencies to the current development module and then builds and installs them.</a>”</p>

<p>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 <code>go</code> command stop after downloading the module, by passing the <code>-d</code> flag to the command:</p>

<pre><code>
$ 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
</code></pre>

<p>With versions of the <code>go</code> command before <code>1.13</code>, you may need to also pass the <code>-m</code> flag to indicate that the path should be interpreted as a module rather than a package.</p>

<p>See also <a href="https://golang.org/issue/33526" rel="nofollow noreferrer">https://golang.org/issue/33526</a>.</p>
