<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Golang in Plain English - Medium]]></title>
        <description><![CDATA[Real Go. No buzzwords. No academic nonsense. Golang in Plain English is a practical Go publication for developers who want to actually understand Go — not just copy-paste snippets. We write about: Real production bugs Performance mistakes Concurrency gotchas Go internals exp - Medium]]></description>
        <link>https://medium.com/golang-in-plain-english?source=rss----5e4a0b56f4a0---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Golang in Plain English - Medium</title>
            <link>https://medium.com/golang-in-plain-english?source=rss----5e4a0b56f4a0---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:59:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/golang-in-plain-english" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Stop Logging “context canceled”]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/stop-logging-context-canceled-c0725c83c5d5?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1536/1*PnZj4EHh0ECeBYId8ubNeg.png" width="1536"></a></p><p class="medium-feed-snippet">The most useless Go error in production (and how to fix it)</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/stop-logging-context-canceled-c0725c83c5d5?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/stop-logging-context-canceled-c0725c83c5d5?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0725c83c5d5</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 17:33:06 GMT</pubDate>
            <atom:updated>2026-06-12T17:33:06.070Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[20 Go Interview Questions That Separate Juniors from Seniors]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/20-go-interview-questions-that-separate-juniors-from-seniors-2813e813001d?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1600/1*MAejXYqO1KpcR-BgzTj0dg.png" width="1600"></a></p><p class="medium-feed-snippet">I&#x2019;ve been on both sides of the table. These are the ones that actually matter.</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/20-go-interview-questions-that-separate-juniors-from-seniors-2813e813001d?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/20-go-interview-questions-that-separate-juniors-from-seniors-2813e813001d?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/2813e813001d</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 14:06:01 GMT</pubDate>
            <atom:updated>2026-04-13T14:06:01.522Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How We Cut 77% Off a Massive Go Binary Without Removing a Single Feature]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/how-we-cut-77-off-a-massive-go-binary-without-removing-a-single-feature-7a372d2aabd0?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/735/1*Qr2SWK4EaC0ugbz_098jFw.jpeg" width="735"></a></p><p class="medium-feed-snippet">The artifact went from 428 MiB to 1.22 GiB over five years.</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/how-we-cut-77-off-a-massive-go-binary-without-removing-a-single-feature-7a372d2aabd0?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/how-we-cut-77-off-a-massive-go-binary-without-removing-a-single-feature-7a372d2aabd0?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/7a372d2aabd0</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Thu, 26 Feb 2026 09:22:48 GMT</pubDate>
            <atom:updated>2026-02-26T09:22:49.961Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Build a Complete REST API in Go — From Zero to CRUD in 20 Minutes]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/build-a-complete-rest-api-in-go-from-zero-to-crud-in-20-minutes-443099393fcc?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1408/1*_WkmKK3eAFvPldSpUmDKfQ.png" width="1408"></a></p><p class="medium-feed-snippet">No frameworks, no magic. Just Go, gorilla/mux, and clean code that actually ships.</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/build-a-complete-rest-api-in-go-from-zero-to-crud-in-20-minutes-443099393fcc?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/build-a-complete-rest-api-in-go-from-zero-to-crud-in-20-minutes-443099393fcc?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/443099393fcc</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Wed, 25 Feb 2026 05:26:09 GMT</pubDate>
            <atom:updated>2026-02-25T05:26:09.586Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Go’s Standard Library Handles Strings, I/O, and Files Better Than You’d Expect]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/gos-standard-library-handles-strings-i-o-and-files-better-than-you-d-expect-0ad3464b022e?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1600/1*FdPwVuw-N6OwYvhT-smVIQ.png" width="1600"></a></p><p class="medium-feed-snippet">Forget third-party packages for the basics &#x2014; Go ships with everything you need</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/gos-standard-library-handles-strings-i-o-and-files-better-than-you-d-expect-0ad3464b022e?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/gos-standard-library-handles-strings-i-o-and-files-better-than-you-d-expect-0ad3464b022e?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/0ad3464b022e</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[golang-development]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Fri, 20 Feb 2026 14:49:04 GMT</pubDate>
            <atom:updated>2026-02-20T14:49:04.724Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Every Go Command You Need and What It Actually Does]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/every-go-command-you-need-and-what-it-actually-does-924e22d39372?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1600/1*R7f36I5yGiNcYyVywqtBmg.png" width="1600"></a></p><p class="medium-feed-snippet">Modules, packages, versioning, and the go.mod file &#x2014; explained without the jargon</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/every-go-command-you-need-and-what-it-actually-does-924e22d39372?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/every-go-command-you-need-and-what-it-actually-does-924e22d39372?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/924e22d39372</guid>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 05:56:02 GMT</pubDate>
            <atom:updated>2026-02-18T05:56:02.609Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Go’s Select Statement Is a Switch for Channels — And It’s More Powerful Than You Think]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/gos-select-statement-is-a-switch-for-channels-and-it-s-more-powerful-than-you-think-78930d3fe009?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1600/1*abx-IzgueOuztfjIfv75yQ.png" width="1600"></a></p><p class="medium-feed-snippet">Part 3: How to multiplex channels, set timeouts, and stop goroutine leaks before they eat your memory</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/gos-select-statement-is-a-switch-for-channels-and-it-s-more-powerful-than-you-think-78930d3fe009?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/gos-select-statement-is-a-switch-for-channels-and-it-s-more-powerful-than-you-think-78930d3fe009?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/78930d3fe009</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 17:11:22 GMT</pubDate>
            <atom:updated>2026-02-17T17:11:22.408Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Part 2:Stop Using time.Sleep to Wait for Goroutines — Here’s What Go Actually Gives You]]></title>
            <link>https://medium.com/golang-in-plain-english/stop-using-time-sleep-to-wait-for-goroutines-heres-what-go-actually-gives-you-54e3629f5b85?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/54e3629f5b85</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 05:00:32 GMT</pubDate>
            <atom:updated>2026-02-17T17:03:48.249Z</atom:updated>
            <content:encoded><![CDATA[<h4>WaitGroups and Channels are Go’s answer to the concurrency chaos. And they’re stupidly elegant.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0CjDpC-LRLL0bC_xRWVlQ.png" /></figure><p>If you’ve written goroutines before, you’ve probably done this:</p><pre>time.Sleep(3 * time.Second) // please god let the goroutine finish by now</pre><p>We’ve all been there. It works on your machine, it works in demos, and then it fails spectacularly in production at 2 AM. Because the goroutine took 3.1 seconds that one time.</p><p>Go gives you two proper tools for this: <strong>WaitGroups</strong> for when you just need goroutines to finish, and <strong>Channels</strong> for when goroutines need to actually talk to each other.</p><p>Let’s dig in.</p><h3>WaitGroups: “Just Tell Me When You’re Done”</h3><p>A WaitGroup is the simplest synchronization tool in Go. Think of it as a counter. You tell it how many goroutines to wait for, each goroutine says “I’m done” when it finishes, and the main goroutine blocks until the counter hits zero.</p><p>Three methods. That’s all you need to know.</p><pre>var wg sync.WaitGroup<br>wg.Add(n)    // &quot;Hey, I&#39;m launching n goroutines&quot;<br>wg.Done()    // &quot;One goroutine just finished&quot; (decrements counter by 1)<br>wg.Wait()    // &quot;Block here until the counter reaches 0&quot;</pre><p>Here’s a real example:</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>    &quot;time&quot;<br>)<br>func fetchData(source string, wg *sync.WaitGroup) {<br>    defer wg.Done() // always use defer - it runs even if the function panics<br>    fmt.Printf(&quot;Fetching from %s...\n&quot;, source)<br>    time.Sleep(2 * time.Second) // simulate network call<br>    fmt.Printf(&quot;Got data from %s\n&quot;, source)<br>}<br>func main() {<br>    var wg sync.WaitGroup<br>    sources := []string{&quot;Database&quot;, &quot;Cache&quot;, &quot;External API&quot;}<br>    wg.Add(len(sources))<br>    for _, source := range sources {<br>        go fetchData(source, &amp;wg)<br>    }<br>    wg.Wait() // blocks until all three goroutines call Done()<br>    fmt.Println(&quot;All data fetched!&quot;)<br>}</pre><p>Output:</p><pre>Fetching from External API...<br>Fetching from Database...<br>Fetching from Cache...<br>Got data from Cache<br>Got data from Database<br>Got data from External API<br>All data fetched!</pre><p>All three fetch operations run concurrently. The wg.Wait() call blocks until every goroutine has called wg.Done(). No sleep hacks. No guessing. It just works.</p><h3>A Common Mistake</h3><p>Pass the WaitGroup by <strong>pointer</strong>, not by value. If you pass it by value, each goroutine gets its own copy and calls Done() on a different counter. The original WaitGroup never reaches zero, and your program hangs forever.</p><pre>// WRONG — wg is copied, main goroutine waits forever<br>go fetchData(source, wg)</pre><pre>// RIGHT — passes a pointer to the same WaitGroup<br>go fetchData(source, &amp;wg)</pre><p>I’ve seen experienced developers burn 30 minutes debugging this. Don’t be that person.</p><h3>Channels: Goroutines Need to Talk</h3><p>WaitGroups are great when you just need to wait. But what if a goroutine produces a result and you need to use it somewhere else? That’s where channels come in.</p><p>There’s a famous Go proverb:</p><blockquote><em>“Do not communicate by sharing memory; instead, share memory by communicating.” — Rob Pike</em></blockquote><p>In most languages, goroutines (or threads) share some variable, and you slap a mutex on it to prevent race conditions. In Go, the preferred way is channels — a typed conduit through which goroutines send and receive values.</p><h3>Creating a Channel</h3><pre>// Declare it<br>var ch chan string<br>// Or create it with make (this is what you&#39;ll actually use)<br>ch := make(chan string)</pre><h3>Sending and Receiving</h3><pre>ch &lt;- &quot;hello&quot;      // send &quot;hello&quot; into the channel<br>msg := &lt;-ch        // receive a value from the channel</pre><p>The &lt;- operator does double duty. When it&#39;s on the left of the channel, you&#39;re sending. When it&#39;s on the right (before the channel), you&#39;re receiving.</p><p>Here’s a simple example:</p><pre>package main<br>import &quot;fmt&quot;<br>func greet(ch chan string) {<br>    ch &lt;- &quot;Hey there!&quot; // send a value into the channel<br>}<br>func main() {<br>    ch := make(chan string)<br>    go greet(ch)<br>    msg := &lt;-ch // blocks until greet() sends something<br>    fmt.Println(msg) // &quot;Hey there!&quot;<br>}</pre><p>Notice something? There’s no WaitGroup. There’s no time.Sleep. The &lt;-ch receive operation <em>blocks</em> until the goroutine sends a value. The channel itself acts as a synchronization mechanism. Pretty slick.</p><h3>Channels Block by Default</h3><p>This is the most important thing to understand about channels. By default (unbuffered channels), <strong>sends block until someone receives, and receives block until someone sends.</strong></p><pre>package main<br>import &quot;fmt&quot;<br>func main() {<br>    ch := make(chan int)<br>    ch &lt;- 42 // DEADLOCK! Nobody is receiving.<br>    fmt.Println(&lt;-ch)<br>}</pre><p>This program panics:</p><pre>fatal error: all goroutines are asleep - deadlock!</pre><p>The main goroutine tries to send 42 into the channel, but nobody&#39;s listening on the other end. It blocks. And since there&#39;s nobody else to unblock it, Go detects the deadlock and crashes.</p><p>The fix? Make sure there’s a goroutine ready to receive:</p><pre>package main<br>import &quot;fmt&quot;<br>func main() {<br>    ch := make(chan int)<br>    go func() {<br>        ch &lt;- 42 // sends in a separate goroutine<br>    }()<br>    val := &lt;-ch // main goroutine receives<br>    fmt.Println(val) // 42<br>}</pre><h3>A Practical Example: Fan-Out Pattern</h3><p>Let’s say you need to check if several websites are up. Doing it sequentially is slow. Let’s use goroutines and a channel to collect results.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;net/http&quot;<br>    &quot;time&quot;<br>)<br>type Result struct {<br>    URL    string<br>    Status string<br>    Err    error<br>}<br>func checkSite(url string, ch chan Result) {<br>    client := http.Client{Timeout: 5 * time.Second}<br>    resp, err := client.Get(url)<br>    if err != nil {<br>        ch &lt;- Result{URL: url, Err: err}<br>        return<br>    }<br>    defer resp.Body.Close()<br>    ch &lt;- Result{URL: url, Status: resp.Status}<br>}<br>func main() {<br>    sites := []string{<br>        &quot;https://google.com&quot;,<br>        &quot;https://github.com&quot;,<br>        &quot;https://golang.org&quot;,<br>        &quot;https://httpstat.us/500&quot;,<br>    }<br>    ch := make(chan Result)<br>    for _, site := range sites {<br>        go checkSite(site, ch)<br>    }<br>    // Collect results<br>    for i := 0; i &lt; len(sites); i++ {<br>        result := &lt;-ch<br>        if result.Err != nil {<br>            fmt.Printf(&quot;%-30s ERROR: %v\n&quot;, result.URL, result.Err)<br>        } else {<br>            fmt.Printf(&quot;%-30s %s\n&quot;, result.URL, result.Status)<br>        }<br>    }<br>}</pre><p>Four HTTP requests fire concurrently. Results flow back through the channel as they complete. The fastest site reports first. The total time is roughly equal to the slowest site, not the sum of all four.</p><h3>Buffered Channels: A Little Breathing Room</h3><p>Regular (unbuffered) channels require a sender and receiver to be ready at the same time. It’s like a phone call — both parties need to be on the line.</p><p>Buffered channels are more like a mailbox. You can drop off a few letters even if nobody’s checking the mail yet — as long as the mailbox isn’t full.</p><pre>// Unbuffered — blocks immediately on send if no receiver<br>ch := make(chan int)<br>// Buffered - can hold up to 3 values before blocking<br>ch := make(chan int, 3)</pre><pre>package main<br>import &quot;fmt&quot;<br>func main() {<br>    ch := make(chan string, 2) // buffer size of 2<br>    ch &lt;- &quot;first&quot;  // doesn&#39;t block - buffer has space<br>    ch &lt;- &quot;second&quot; // doesn&#39;t block - buffer still has space<br>    // ch &lt;- &quot;third&quot; // THIS would block - buffer is full<br>    fmt.Println(&lt;-ch) // &quot;first&quot;<br>    fmt.Println(&lt;-ch) // &quot;second&quot;<br>}</pre><h3>When to use buffered channels?</h3><ul><li>You know how many goroutines you’re launching and want to limit work queued up</li><li>You want to decouple the sender from the receiver slightly</li><li>You’re building a worker pool with a fixed number of jobs</li></ul><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>)<br>func worker(id int, jobs &lt;-chan int, wg *sync.WaitGroup) {<br>    defer wg.Done()<br>    for job := range jobs {<br>        fmt.Printf(&quot;Worker %d processing job %d\n&quot;, id, job)<br>    }<br>}<br>func main() {<br>    jobs := make(chan int, 10) // buffer 10 jobs<br>    var wg sync.WaitGroup<br>    // Start 3 workers<br>    for w := 1; w &lt;= 3; w++ {<br>        wg.Add(1)<br>        go worker(w, jobs, &amp;wg)<br>    }<br>    // Send 9 jobs<br>    for j := 1; j &lt;= 9; j++ {<br>        jobs &lt;- j<br>    }<br>    close(jobs) // signal that no more jobs are coming<br>    wg.Wait()<br>    fmt.Println(&quot;All jobs processed&quot;)<br>}</pre><h3>Buffer Capacity and Length</h3><p>Two built-in functions you should know:</p><pre>ch := make(chan int, 5)<br>ch &lt;- 1<br>ch &lt;- 2<br>fmt.Println(cap(ch)) // 5 - total capacity<br>fmt.Println(len(ch)) // 2 - current number of elements in buffer</pre><p>Quick note: the length of an unbuffered channel is <em>always</em> zero. There’s no buffer to hold anything.</p><h3>Closing a Channel</h3><p>When you’re done sending values on a channel, you close it. This tells receivers “there’s nothing more coming.”</p><pre>close(ch)</pre><p>Receivers can check if a channel is closed:</p><pre>val, ok := &lt;-ch<br>// ok == true  → channel is open, val is a real value<br>// ok == false → channel is closed, val is the zero value</pre><p>The most common use is with range — it automatically stops when the channel closes:</p><pre>package main<br>import &quot;fmt&quot;<br>func generateNumbers(ch chan int) {<br>    for i := 1; i &lt;= 5; i++ {<br>        ch &lt;- i<br>    }<br>    close(ch) // done sending<br>}<br>func main() {<br>    ch := make(chan int)<br>    go generateNumbers(ch)<br>    for num := range ch { // loops until channel is closed<br>        fmt.Println(num)<br>    }<br>}</pre><p>Output:</p><pre>1<br>2<br>3<br>4<br>5</pre><h3>Two Things That Will Crash Your Program</h3><ol><li><strong>Sending to a closed channel</strong> — instant panic</li></ol><pre>ch := make(chan int)<br>close(ch)<br>ch &lt;- 1 // panic: send on closed channel</pre><ol><li><strong>Closing an already closed channel</strong> — instant panic</li></ol><pre>ch := make(chan int)<br>close(ch)<br>close(ch) // panic: close of closed channel</pre><p>The rule is simple: only the sender should close the channel, and only close it once. If you have multiple senders, use a WaitGroup to coordinate who closes it.</p><h3>Channel Direction: Being Explicit</h3><p>You can restrict a channel parameter to send-only or receive-only. This makes your code clearer and catches bugs at compile time.</p><pre>func producer(ch chan&lt;- int) { // can only SEND to ch<br>    ch &lt;- 42<br>}<br>func consumer(ch &lt;-chan int) { // can only RECEIVE from ch<br>    val := &lt;-ch<br>    fmt.Println(val)<br>}<br>func main() {<br>    ch := make(chan int)<br>    go producer(ch)<br>    consumer(ch)<br>}</pre><p>If producer accidentally tries to read from ch, the compiler catches it. It&#39;s a small thing, but it makes large codebases much easier to reason about.</p><h3>Putting It All Together: A Pipeline</h3><p>Channels really shine when you chain goroutines together. Each stage does some work and passes the result to the next.</p><pre>package main<br>import &quot;fmt&quot;<br>// Stage 1: Generate numbers<br>func generate(nums ...int) &lt;-chan int {<br>    out := make(chan int)<br>    go func() {<br>        for _, n := range nums {<br>            out &lt;- n<br>        }<br>        close(out)<br>    }()<br>    return out<br>}<br>// Stage 2: Square each number<br>func square(in &lt;-chan int) &lt;-chan int {<br>    out := make(chan int)<br>    go func() {<br>        for n := range in {<br>            out &lt;- n * n<br>        }<br>        close(out)<br>    }()<br>    return out<br>}<br>// Stage 3: Add 10 to each number<br>func addTen(in &lt;-chan int) &lt;-chan int {<br>    out := make(chan int)<br>    go func() {<br>        for n := range in {<br>            out &lt;- n + 10<br>        }<br>        close(out)<br>    }()<br>    return out<br>}<br>func main() {<br>    // Chain the pipeline: generate -&gt; square -&gt; addTen<br>    nums := generate(2, 3, 4, 5)<br>    squared := square(nums)<br>    result := addTen(squared)<br>    for val := range result {<br>        fmt.Println(val) // 14, 19, 26, 35<br>    }<br>}</pre><p>Each stage runs in its own goroutine. Data flows through channels like water through pipes. And the best part? Each stage doesn’t know or care about the others. You can rearrange, add, or remove stages without touching the rest.</p><h3>Quick Recap</h3><ul><li><strong>WaitGroups</strong>: counter-based synchronization. Add, Done, Wait. Pass by pointer.</li><li><strong>Channels</strong>: typed pipes for goroutine communication. make(chan T)</li><li><strong>Unbuffered channels</strong>: send blocks until receive, receive blocks until send</li><li><strong>Buffered channels</strong>: make(chan T, n) — blocks only when full (send) or empty (receive)</li><li><strong>Closing channels</strong>: signals “no more data.” Only the sender closes. Closing twice panics.</li><li><strong>Channel direction</strong>: chan&lt;- (send-only), &lt;-chan (receive-only) for compile-time safety</li><li><strong>Pipelines</strong>: chain goroutines with channels for clean data flow</li></ul><p><em>This article is part of the “Go from Scratch” series. For the complete guide with all examples and exercises, grab the free book on </em><a href="https://gum.co/u/b23yfoia"><em>Gumroad</em></a><em>.</em></p><h3>Go from Scratch — Full Series</h3><ol><li><a href="https://medium.com/golang-in-plain-english/why-goroutines-will-change-how-you-think-about-code-6208d2b980b9">Why Goroutines Will Change How You Think About Code</a></li><li><strong>WaitGroups &amp; Channels</strong> <em>(you are here)</em></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54e3629f5b85" width="1" height="1" alt=""><hr><p><a href="https://medium.com/golang-in-plain-english/stop-using-time-sleep-to-wait-for-goroutines-heres-what-go-actually-gives-you-54e3629f5b85">Part 2:Stop Using time.Sleep to Wait for Goroutines — Here’s What Go Actually Gives You</a> was originally published in <a href="https://medium.com/golang-in-plain-english">Golang in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Goroutines Will Change How You Think About Code]]></title>
            <link>https://medium.com/golang-in-plain-english/why-goroutines-will-change-how-you-think-about-code-6208d2b980b9?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/6208d2b980b9</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Mon, 16 Feb 2026 06:55:31 GMT</pubDate>
            <atom:updated>2026-02-16T06:55:31.318Z</atom:updated>
            <content:encoded><![CDATA[<h4>Go’s concurrency model isn’t just fast — it’s a completely different way of solving problems</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hns_6GUduoxYwZDpN7-PRw.png" /></figure><p>I still remember the first time I ran a goroutine. I had just come from writing Java, where spinning up threads felt like filing a tax return — verbose, heavy, and you were never 100% sure things wouldn’t blow up.</p><p>Then I typed go in front of a function call. And that was it.</p><p>No thread pool configuration. No executor service. No 15 lines of boilerplate. Just… go.</p><p>But before we get into goroutines, let’s talk about something most tutorials skip over too quickly — the difference between sequential, concurrent, and parallel processing. Because if you don’t get this part right, the rest won’t click.</p><h3>Sequential Processing: One Thing at a Time</h3><p>Think of a coffee shop with one barista. One customer walks up, orders, the barista makes the coffee, hands it over, and <em>then</em> calls the next person. Nobody else gets served until the current order is done.</p><p>That’s sequential processing. Your CPU has one core, and it does one task from start to finish before touching the next.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br>func makeOrder(order string) {<br>    fmt.Printf(&quot;Started making: %s\n&quot;, order)<br>    time.Sleep(2 * time.Second) // simulate work<br>    fmt.Printf(&quot;Finished: %s\n&quot;, order)<br>}<br>func main() {<br>    makeOrder(&quot;Latte&quot;)<br>    makeOrder(&quot;Espresso&quot;)<br>    makeOrder(&quot;Cappuccino&quot;)<br>}</pre><p>Output:</p><pre>Started making: Latte<br>Finished: Latte<br>Started making: Espresso<br>Finished: Espresso<br>Started making: Cappuccino<br>Finished: Cappuccino</pre><p>Total time? About 6 seconds. Each order waits patiently in line.</p><h3>Concurrent Processing: Juggling, Not Cloning</h3><p>Now imagine that same single barista, but she’s good. Really good. She starts the espresso machine, and while it’s pulling the shot, she steams milk for the latte. She’s not doing two things at the <em>exact</em> same instant — she’s switching between tasks so fast it looks like she is.</p><p>That’s concurrency. One core, multiple tasks in progress. The key word is <em>in progress</em> — not <em>simultaneously</em>.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br>func makeOrder(order string) {<br>    fmt.Printf(&quot;Started making: %s\n&quot;, order)<br>    time.Sleep(2 * time.Second)<br>    fmt.Printf(&quot;Finished: %s\n&quot;, order)<br>}<br>func main() {<br>    go makeOrder(&quot;Latte&quot;)<br>    go makeOrder(&quot;Espresso&quot;)<br>    go makeOrder(&quot;Cappuccino&quot;)<br>    time.Sleep(3 * time.Second) // wait for goroutines (we&#39;ll fix this later)<br>}</pre><p>Output (order may vary):</p><pre>Started making: Cappuccino<br>Started making: Latte<br>Started making: Espresso<br>Finished: Espresso<br>Finished: Latte<br>Finished: Cappuccino</pre><p>All three start almost immediately. Total time? About 2 seconds. Same CPU, way better throughput.</p><h3>Parallel Processing: Actually Doing Multiple Things at Once</h3><p>Now the coffee shop hires two more baristas. Three baristas, three customers, three orders being made at the <em>exact same time</em>. No switching, no juggling — genuine simultaneous work.</p><p>That’s parallelism. Multiple CPU cores, each handling its own task independently.</p><p>Here’s the thing that trips people up: <strong>concurrency is about structure, parallelism is about execution.</strong> You can write concurrent code that runs on a single core. You can’t have parallelism without multiple cores.</p><p>Go makes this distinction beautifully. You write concurrent code with goroutines, and the Go runtime decides whether to run them in parallel based on available CPU cores.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;runtime&quot;<br>)<br>func main() {<br>    fmt.Println(&quot;Number of CPUs:&quot;, runtime.NumCPU())<br>    fmt.Println(&quot;GOMAXPROCS:&quot;, runtime.GOMAXPROCS(0))<br>}</pre><p>runtime.NumCPU() tells you how many logical processors your machine has. GOMAXPROCS controls how many OS threads Go will use for your goroutines. By default, it matches your CPU count.</p><h3>Enter Goroutines</h3><p>A goroutine is a function that runs concurrently with other goroutines. That’s it. No special class to extend. No interface to implement. Just the go keyword.</p><pre>go myFunction()</pre><p>Behind the scenes, a goroutine is <em>not</em> an OS thread. It’s way lighter. An OS thread typically needs about 1MB of stack memory. A goroutine starts with just 2KB. You can spin up thousands — even millions — without breaking a sweat.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>)<br>func printNumber(n int, wg *sync.WaitGroup) {<br>    defer wg.Done()<br>    fmt.Printf(&quot;Goroutine %d is running\n&quot;, n)<br>}<br>func main() {<br>    var wg sync.WaitGroup<br>    for i := 1; i &lt;= 10; i++ {<br>        wg.Add(1)<br>        go printNumber(i, &amp;wg)<br>    }<br>    wg.Wait()<br>    fmt.Println(&quot;All goroutines finished&quot;)<br>}</pre><p>Run this a few times. Notice how the numbers come out in a different order each time? That’s concurrency in action — the scheduler decides who runs when.</p><h3>Anonymous Goroutines</h3><p>You don’t always need a named function. Sometimes you want to fire off a quick concurrent task inline.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;time&quot;<br>)<br>func main() {<br>    go func() {<br>        fmt.Println(&quot;I&#39;m running in the background!&quot;)<br>    }()<br>    go func(msg string) {<br>        fmt.Println(msg)<br>    }(&quot;Hello from an anonymous goroutine&quot;)<br>    time.Sleep(1 * time.Second)<br>}</pre><p>The syntax looks a bit funky at first — you define the function and immediately call it with () at the end. But you&#39;ll get used to it fast. Anonymous goroutines are everywhere in real Go code.</p><h3>The Go Runtime Scheduler: Where the Magic Happens</h3><p>Here’s where things get interesting. When you start a Go program, the runtime creates OS-level threads and then multiplexes goroutines onto them. It’s called <strong>M:N scheduling</strong> — M goroutines mapped onto N OS threads.</p><p>The scheduler uses three core concepts:</p><ul><li><strong>G</strong> — a goroutine</li><li><strong>M</strong> — an OS thread (machine)</li><li><strong>P</strong> — a logical processor (context for scheduling)</li></ul><p>Each P has a <strong>Local Run Queue (LRQ)</strong> of goroutines waiting to execute. There’s also a <strong>Global Run Queue (GRQ)</strong> for goroutines that haven’t been assigned to a P yet.</p><p>Here’s what this looks like in practice:</p><pre>Global Run Queue: [G7, G8, G9, G10]<br>P1 (Logical CPU 1)          P2 (Logical CPU 2)<br>  Local Queue: [G2, G3]       Local Queue: [G5, G6]<br>  Running: G1                  Running: G4<br>  OS Thread: M1                OS Thread: M2</pre><p>The scheduler picks goroutines from the local queue and runs them on the OS thread. When a goroutine blocks (say, on a network call), the scheduler swaps it out and runs another one. You never notice, and you definitely don’t have to manage it yourself.</p><h3>Cooperative Scheduling: Playing Nice</h3><p>Go’s scheduler is <strong>cooperative</strong>, not preemptive. That means goroutines yield control voluntarily at certain checkpoints rather than being forcefully interrupted.</p><p>When does a goroutine yield?</p><ul><li><strong>Function calls</strong> — every function call is a potential scheduling point</li><li><strong>Channel operations</strong> — sending or receiving on a channel</li><li><strong>Network calls</strong> — any I/O operation</li><li><strong>Garbage collection</strong> — when the GC kicks in</li><li><strong>The </strong><strong>go keyword itself</strong> — launching a new goroutine</li></ul><p>This is why you’ll sometimes see a goroutine that runs a tight loop without any of these operations hog the CPU. It never yields. The fix is usually to add a runtime.Gosched() call, but honestly, this is rare in real-world code because most goroutines do I/O or channel operations.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;runtime&quot;<br>)<br>func main() {<br>    go func() {<br>        for i := 0; i &lt; 5; i++ {<br>            fmt.Println(&quot;Goroutine:&quot;, i)<br>            runtime.Gosched() // yield to let other goroutines run<br>        }<br>    }()<br>    for i := 0; i &lt; 5; i++ {<br>        fmt.Println(&quot;Main:&quot;, i)<br>    }<br>}</pre><h3>Goroutines vs Threads: Why This Matters</h3><p>Let’s be blunt about why goroutines are a big deal compared to traditional threads:</p><p>FeatureOS ThreadsGoroutinesStack size~1 MB (fixed)~2 KB (grows as needed)Creation timeSlow (kernel call)Fast (user-space)SchedulingOS scheduler (preemptive)Go scheduler (cooperative)Context switchExpensive (~1–2 μs)Cheap (~200 ns)CommunicationShared memory + mutexesChannels (built-in)Typical countHundreds to low thousandsHundreds of thousands</p><p>I once ran a benchmark spinning up 100,000 goroutines on a laptop. It used about 200MB of RAM and finished in under a second. Try that with Java threads and your machine will start making noises.</p><pre>package main<br>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>)<br>func main() {<br>    var wg sync.WaitGroup<br>    count := 100000<br>    wg.Add(count)<br>    for i := 0; i &lt; count; i++ {<br>        go func(id int) {<br>            defer wg.Done()<br>            // each goroutine does a tiny bit of work<br>            _ = id * id<br>        }(i)<br>    }<br>    wg.Wait()<br>    fmt.Printf(&quot;Successfully ran %d goroutines\n&quot;, count)<br>}</pre><h3>The Main Goroutine Problem</h3><p>There’s one gotcha that catches every Go beginner. When the main function exits, <em>all</em> goroutines die with it. No mercy, no cleanup, no waiting.</p><pre>package main<br>import &quot;fmt&quot;<br>func main() {<br>    go fmt.Println(&quot;Will I print?&quot;)<br>    // main exits immediately - the goroutine might never execute<br>}</pre><p>Run this and there’s a good chance you’ll see nothing. The main goroutine finishes before the other goroutine even starts.</p><p>We used time.Sleep earlier as a quick hack, but that&#39;s terrible for real code. What if the goroutine takes longer than you expected? What if it finishes instantly and you&#39;re just wasting time sleeping?</p><p>The proper solution involves WaitGroups and Channels — which is exactly what we’ll cover in the next article.</p><h3>Quick Recap</h3><ul><li><strong>Sequential</strong>: one task at a time, simple but slow</li><li><strong>Concurrent</strong>: multiple tasks in progress, switching between them</li><li><strong>Parallel</strong>: multiple tasks executing at the exact same time on different cores</li><li><strong>Goroutines</strong>: lightweight, user-space threads managed by Go’s runtime</li><li><strong>The scheduler</strong>: maps goroutines to OS threads using M:N scheduling with local and global run queues</li><li><strong>Cooperative scheduling</strong>: goroutines yield at function calls, channel ops, I/O, and GC</li><li><strong>Main goroutine exits = everything dies</strong></li></ul><p><em>This article is part of the “Go from Scratch” series. For the complete guide with all examples and exercises, grab the free book on </em><a href="https://gum.co/u/b23yfoia"><em>Gumroad</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6208d2b980b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/golang-in-plain-english/why-goroutines-will-change-how-you-think-about-code-6208d2b980b9">Why Goroutines Will Change How You Think About Code</a> was originally published in <a href="https://medium.com/golang-in-plain-english">Golang in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go 1.26 Is Here — And It’s Bigger Than It Looks]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/golang-in-plain-english/go-1-26-is-here-and-its-bigger-than-it-looks-3252b467e5f3?source=rss----5e4a0b56f4a0---4"><img src="https://cdn-images-1.medium.com/max/1536/1*R30NKi_dC8mf8uF0tfNNJA.png" width="1536"></a></p><p class="medium-feed-snippet">New GC, goroutine leak detection, smarter go fix, and serious security upgrades</p><p class="medium-feed-link"><a href="https://medium.com/golang-in-plain-english/go-1-26-is-here-and-its-bigger-than-it-looks-3252b467e5f3?source=rss----5e4a0b56f4a0---4">Continue reading on Golang in Plain English »</a></p></div>]]></description>
            <link>https://medium.com/golang-in-plain-english/go-1-26-is-here-and-its-bigger-than-it-looks-3252b467e5f3?source=rss----5e4a0b56f4a0---4</link>
            <guid isPermaLink="false">https://medium.com/p/3252b467e5f3</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Braham Garg | DevOps | Golang | Python | AWS | K8s]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 04:22:04 GMT</pubDate>
            <atom:updated>2026-02-12T04:22:04.697Z</atom:updated>
        </item>
    </channel>
</rss>