<p>I am trying to build out my Custom Resource project in Kubebuilder but it seems like I am missing my controller gen whenever I build it out. I keep getting the error:</p>
<pre><code>/Users/*****/Kubernetes/postgres-writer-operator/bin/controller-gen object:headerFile=&quot;hack/boilerplate.go.txt&quot; paths=&quot;./...&quot;
bash: /Users/****/Kubernetes/postgres-writer-operator/bin/controller-gen: No such file or directory
make: *** [generate] Error 127
Error: failed to create API: unable to run post-scaffold tasks of &quot;base.go.kubebuilder.io/v3&quot;: exit status 2
Usage:
  kubebuilder create api [flags]
</code></pre>
<p>I am new to Kubernetes and am following the tutorial below:
<a href="https://yash-kukreja-98.medium.com/develop-on-kubernetes-series-operator-dev-understanding-and-dissecting-kubebuilder-4321d3ecd7d6" rel="nofollow noreferrer">https://yash-kukreja-98.medium.com/develop-on-kubernetes-series-operator-dev-understanding-and-dissecting-kubebuilder-4321d3ecd7d6</a></p>
<p>First I ran the following command that bootstraps my project:</p>
<pre><code>kubebuilder init \
--domain yash.com \
--repo github.com/yashvardhan-kukreja/postgres-writer-operator \
--project-name postgres-writer-operator \
--license apache2 \
--skip-go-version-check
</code></pre>
<p>After running the command I went into my directory and found the following files and folders:
<a href="https://i.stack.imgur.com/gqMRE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gqMRE.png" alt="enter image description here" /></a></p>
<p>Then the next step was to run bootstrapper for my custom resource PostgresWriter and attach it to the operator.</p>
<pre><code>kubebuilder create api \
--group demo \
--version v1 \
--kind PostgresWriter \
--resource true \
--controller true \
--namespaced true
</code></pre>
<p>This resulted in the error listed above. How do I generate my controller gen using kubebuilder? Is there a step I am missing here?</p>
<p>FYI by go version is 1.18.</p>

<p>Not a perfect solution, this should work with the latest go version but it doesn't, so I had to downgrade the go version to 1.17 and then it worked</p>
<p>Summarizing what I learned from this article on downgrading your go version.
<a href="https://blog.notmyhostna.me/posts/downgrade-go-installed-with-homebrew/" rel="noreferrer">https://blog.notmyhostna.me/posts/downgrade-go-installed-with-homebrew/</a></p>
<p>Install version 1.17 go</p>
<pre><code>brew install go@1.17
</code></pre>
<p>You will still see that the version didn't change, so you need to unlink the current version by running</p>
<pre><code>brew unlink go
</code></pre>
<p>Now you can link the 1.17 version of Go, so when you do go version you'll get 1.17.</p>
<pre><code>brew link --force go@1.17
</code></pre>
<p>Voila! You should now see that your current version is 1.17 and you'll be able to successfully run Kubebuilder.</p>
