<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Words with Marcus]]></title><description><![CDATA[Words with Marcus]]></description><link>https://words.marcuslew.is</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 20:13:44 GMT</lastBuildDate><atom:link href="https://words.marcuslew.is/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Compiling go for Apple Silicon]]></title><description><![CDATA[Compiling go for Apple Silicon devices is fairly straight forward. To get a working binary we'll need an x86 device to use for cross-compilation. In this case we're going to use a DigitalOcean droplet.

Note! Currently only the unreleased go 1.16 sup...]]></description><link>https://words.marcuslew.is/compiling-go-for-apple-silicon</link><guid isPermaLink="true">https://words.marcuslew.is/compiling-go-for-apple-silicon</guid><category><![CDATA[Apple]]></category><category><![CDATA[Go Language]]></category><category><![CDATA[DigitalOcean]]></category><dc:creator><![CDATA[Marcus Lewis]]></dc:creator><pubDate>Sun, 06 Dec 2020 18:20:51 GMT</pubDate><content:encoded><![CDATA[<p>Compiling go for Apple Silicon devices is fairly straight forward. To get a working binary we'll need an x86 device to use for cross-compilation. In this case we're going to use a DigitalOcean droplet.</p>
<blockquote>
<p><strong>Note!</strong> Currently only the unreleased go 1.16 supports Apple Silicon, so we're going to be compiling from the master branch</p>
</blockquote>
<p>We're going to start by creating a new DigitalOcean droplet with Ubuntu 20.04. It's only going to be running for 10 - 15 minutes, so we'll give it a fair bit of processing power to compile go more quickly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1607276611851/ngvQk_8z8.png" alt="image.png" /></p>
<p>Once your droplet has finished creating, grab the public IP address and SSH into it as the root user.</p>
<pre><code class="lang-bash">ssh root@IP_ADDRESS
</code></pre>
<p>To build go from source we need a bootstrap version of go. We can install a copy from Ubuntu's apt repository using the following command.</p>
<pre><code class="lang-bash">apt-get install golang -yy
</code></pre>
<p>Now that you've got a bootstrap compiler we're going to clone down go's GitHub repository and cross-compile it.</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/golang/go.git
<span class="hljs-built_in">cd</span> go/src
GOARCH=arm64 GOOS=darwin ./bootstrap.bash
</code></pre>
<p>Now that we've built our binary we're going to return to our Apple Silicon Mac and copy down the built archive.</p>
<pre><code class="lang-bash">scp root@IP_ADDRESS:~/go-darwin-arm64-bootstrap.tbz .
</code></pre>
<p>Extract this archive using Archive Utility and now it's time to add the <code>bin</code> directory to your path.</p>
<h3 id="zsh">ZSH</h3>
<p>Add the following line to your <code>~/.zshrc</code></p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> PATH=~/go-darwin-arm64-bootstrap/bin:<span class="hljs-variable">$PATH</span>
</code></pre>
<p>Source your new config</p>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> ~/.zshrc
</code></pre>
<h3 id="fish-shell">Fish Shell</h3>
<p>Add the following line to your fish config in <code>~/.config/fish/config.fish</code></p>
<pre><code class="lang-fish">set -gx PATH ~/go-darwin-arm64-bootstrap/bin $PATH
</code></pre>
<p>Source your new config</p>
<pre><code class="lang-fish">source ~/.config/fish/config.fish
</code></pre>
<h2 id="summary">Summary</h2>
<p>You should now have a working go compiler on your path that can create native Apple Silicon binaries! 🎉</p>
]]></content:encoded></item></channel></rss>