Mistakes C/C++ Devs make writing Go
re: &quot;# channels &lt; # goroutines&quot;<p><pre><code>  func doSomethingTwice() error {
      &#x2F;&#x2F; Issue occurs below
      errc := make(chan error)
  
      go func() {
          defer fmt.Println(&quot;done wth a&quot;)
          errc &lt;- doSomething(&quot;a&quot;)
      }()
      go func() {
          defer fmt.Println(&quot;done with b&quot;)
          errc &lt;- doSomething(&quot;b&quot;)
      }()
      err := &lt;-errc
      return err
  }
</code></pre>
&gt; When one routine writes to the channel, the program exits and the other goroutine is lost, building up memory use as a results<p>I&#x27;m not very familiar with go, but my guess would be that since the two goroutines send to an unbuffered channel that is read at most once, the &quot;slower&quot; of the two goroutines will sit there blocking attempting to send to a channel that will never be read. So this would &quot;leak&quot; a goroutine that would consume resources while the process was still running, but it doesn&#x27;t have anything to do with the program exiting.<p><a href="https:&#x2F;&#x2F;golang.org&#x2F;ref&#x2F;spec#Channel_types" rel="nofollow">https:&#x2F;&#x2F;golang.org&#x2F;ref&#x2F;spec#Channel_types</a><p><a href="https:&#x2F;&#x2F;golang.org&#x2F;ref&#x2F;spec#Send_statements" rel="nofollow">https:&#x2F;&#x2F;golang.org&#x2F;ref&#x2F;spec#Send_statements</a><p>&gt; How do we fix this? We simply increase the number of channels to 2<p>The fix is okay but the language is a bit hazy, there&#x27;s still only one channel, but now it&#x27;s a buffered channel with capacity to hold up to 2 messages, so the two goroutines don&#x27;t need to block waiting for a receiver to be ready to synchronously receive the message they are sending.