<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Golang on A Blog for the Uninitialized</title><link>https://www.nilpointer.blog/tags/golang/</link><description>Recent content in Golang on A Blog for the Uninitialized</description><generator>Hugo</generator><language>en-us</language><copyright>&lt;a href="https://www.apache.org/licenses/LICENSE-2.0" target="_blank" rel="noopener"&gt;Licensed under Apache 2.0&lt;/a&gt;</copyright><lastBuildDate>Fri, 13 Mar 2026 10:48:58 -0700</lastBuildDate><atom:link href="https://www.nilpointer.blog/tags/golang/index.xml" rel="self" type="application/rss+xml"/><item><title>On Regular Expressions</title><link>https://www.nilpointer.blog/posts/2026/03/on-regular-expressions/</link><pubDate>Fri, 13 Mar 2026 10:48:58 -0700</pubDate><guid>https://www.nilpointer.blog/posts/2026/03/on-regular-expressions/</guid><description>&lt;p&gt;Way back when, I was primarily a Perl developer. I actually did my first interview for LinkedIn in Perl. I always liked that the language was created by a linguist (I legitimately miss using &lt;code&gt;unless&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Today, though, besides the occasional one-liner, I think Perl is most known for its contributions to how we all (now) use regular expressions (this post isn&amp;rsquo;t going into what they are or how to use them).&lt;/p&gt;</description></item><item><title>Building strings in Golang</title><link>https://www.nilpointer.blog/posts/2026/03/building-strings-in-golang/</link><pubDate>Tue, 10 Mar 2026 15:00:17 -0700</pubDate><guid>https://www.nilpointer.blog/posts/2026/03/building-strings-in-golang/</guid><description>&lt;p&gt;&lt;strong&gt;How do I build a string in Golang?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Building a string seems trivial, and it generally is, but it&amp;rsquo;s a great way to dive into further to understand some of the basics around what makes Golang so interesting.&lt;/p&gt;
&lt;p&gt;First of all, let&amp;rsquo;s note that a &lt;em&gt;string&lt;/em&gt; in Golang is &lt;em&gt;immutable&lt;/em&gt;. That means whenever you want to append to a string, the existing string &lt;em&gt;plus what you&amp;rsquo;re appending&lt;/em&gt; needs to be copied to a new string in memory. This means that when optimizing code, we need to be mindful when we write code that performs these actions many times.&lt;/p&gt;</description></item><item><title>Using the "done" channel in Go</title><link>https://www.nilpointer.blog/posts/2026/02/using-the-done-channel-in-go/</link><pubDate>Fri, 27 Feb 2026 14:29:51 -0800</pubDate><guid>https://www.nilpointer.blog/posts/2026/02/using-the-done-channel-in-go/</guid><description>&lt;p&gt;I wanted to document how a &lt;code&gt;done&lt;/code&gt; channel is most commonly used.&lt;/p&gt;
&lt;p&gt;Mainly because I&amp;rsquo;ve personally found it to be more confusing than it should be.&lt;/p&gt;
&lt;p&gt;It usually looks a bit like this, when following a worker pattern:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;func main() {
 var doneCh = make(chan struct{})

 // Perform some concurrent work
 // ...

 // Wait on that work
 for i := 0; i &amp;lt; 10; i++ {
 &amp;lt;-doneCh
 }
 
 // complete
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I intentially left out a bit here to highlight what a &amp;ldquo;done&amp;rdquo; channel actually looks like.&lt;/p&gt;</description></item><item><title>The Worker Pattern</title><link>https://www.nilpointer.blog/posts/2026/02/the-worker-pattern/</link><pubDate>Thu, 26 Feb 2026 16:09:17 -0800</pubDate><guid>https://www.nilpointer.blog/posts/2026/02/the-worker-pattern/</guid><description>&lt;p&gt;I really like using a worker pattern with &lt;a href="https://www.nilpointer.blog/posts/2026/02/golangs-unbuffered-and-buffered-channels/"
 
 
&gt;unbuffered channels&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;API calls, especially when each can be handled separately and independently, are easily implemented with this pattern, and I&amp;rsquo;ve seen it help tremendously when downloading artifacts for building in CI, for example.&lt;/p&gt;
&lt;p&gt;Instead of setting up a buffered channel with a capacity of 10 in an attempt to concurrently handle 10 requests, you can create an unbuffered channel and read from it using 10 workers.&lt;/p&gt;</description></item><item><title>Golang's unbuffered and buffered channels</title><link>https://www.nilpointer.blog/posts/2026/02/golangs-unbuffered-and-buffered-channels/</link><pubDate>Wed, 25 Feb 2026 16:40:18 -0800</pubDate><guid>https://www.nilpointer.blog/posts/2026/02/golangs-unbuffered-and-buffered-channels/</guid><description>&lt;p&gt;From the &lt;a href="https://go.dev/blog/codelab-share"
 
 
 target="_blank" 
 rel="noopener noreferrer"
 
&gt;official Go Blog&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Do not communicate by sharing memory; instead, share memory by communicating.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;They&amp;rsquo;re awesome because they enable concurrency support &amp;ldquo;out of the box&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;They&amp;rsquo;re basically their own type that implements concurrent safe logic of sharing memory locations of data without the explicit usage of mutexes or locks. The example in the blog link above has some code blocks that show this quite well, actually.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;They can be buffered or unbuffered.&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>A Golang Slice gotcha that...got me</title><link>https://www.nilpointer.blog/posts/2026/02/a-golang-slice-gotcha-that...got-me/</link><pubDate>Sat, 21 Feb 2026 12:33:28 -0800</pubDate><guid>https://www.nilpointer.blog/posts/2026/02/a-golang-slice-gotcha-that...got-me/</guid><description>&lt;p&gt;I was doing some self study the other day, feeling relatively confident building out a &lt;a href="https://en.wikipedia.org/wiki/Trie"
 
 
 target="_blank" 
 rel="noopener noreferrer"
 
&gt;Trie&lt;/a&gt; for an autocomplete function. When checking my work with Gemini, I was recommended something like this as a possible function signature:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;func (t *Trie) collect(n *TrieNode, pfx string, results *[]string) {
 // ...
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Where I started to spiral was the &lt;strong&gt;&lt;code&gt;*[]string&lt;/code&gt;&lt;/strong&gt; type in the final input parameter.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;That&amp;rsquo;s weird looking, isn&amp;rsquo;t it?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In Golang, slices and arrays are often confused. You may say: &lt;em&gt;&amp;ldquo;But aren&amp;rsquo;t slices copied by reference?&amp;rdquo;&lt;/em&gt;&lt;/p&gt;</description></item></channel></rss>