<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Algorithms to Go</title>
    <link>https://yourbasic.org/</link>
    <description>Recent content on Algorithms to Go</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://yourbasic.org/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>2 basic FIFO queue implementations</title>
      <link>https://yourbasic.org/golang/implement-fifo-queue/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/implement-fifo-queue/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/hktang/4243300265 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/queue.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;A simple way to implement a temporary queue data structure in Go is to use a &lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;slice&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to enqueue you use the built-in &lt;code&gt;append&lt;/code&gt; function, and&lt;/li&gt;&#xA;&lt;li&gt;to dequeue you slice off the first element.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;var queue []string&#xA;&#xA;queue = append(queue, &#34;Hello &#34;) &lt;span class=&#34;comment&#34;&gt;// Enqueue&lt;/span&gt;&#xA;queue = append(queue, &#34;world!&#34;)&#xA;&#xA;for len(queue) &gt; 0 {&#xA;&#x9;fmt.Print(queue[0]) &lt;span class=&#34;comment&#34;&gt;// First element&lt;/span&gt;&#xA;&#x9;queue = queue[1:]   &lt;span class=&#34;comment&#34;&gt;// Dequeue&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;Hello world!&lt;/pre&gt;&#xA;&lt;h2 id=&#34;watch-out-for-memory-leaks&#34;&gt;Watch out for memory leaks&lt;/h2&gt;&#xA;&lt;p&gt;You may want to remove the first element before dequeuing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>2 basic set implementations</title>
      <link>https://yourbasic.org/golang/implement-set/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/implement-set/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/996450 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/eggs-in-basket.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;map-implementation&#34;&gt;Map implementation&lt;/h2&gt;&#xA;&lt;p&gt;The idiomatic way to implement a set in Go is to use&#xA;a &lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;map&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;set := make(map[string]bool) &lt;span class=&#34;comment&#34;&gt;// New empty set&lt;/span&gt;&#xA;set[&#34;Foo&#34;] = true            &lt;span class=&#34;comment&#34;&gt;// Add&lt;/span&gt;&#xA;for k := range set {         &lt;span class=&#34;comment&#34;&gt;// Loop&lt;/span&gt;&#xA;&#x9;fmt.Println(k)&#xA;}&#xA;delete(set, &#34;Foo&#34;)    &lt;span class=&#34;comment&#34;&gt;// Delete&lt;/span&gt;&#xA;size := len(set)      &lt;span class=&#34;comment&#34;&gt;// Size&lt;/span&gt;&#xA;exists := set[&#34;Foo&#34;]  &lt;span class=&#34;comment&#34;&gt;// Membership&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;alternative&#34;&gt;Alternative&lt;/h3&gt;&#xA;&lt;p&gt;If the memory used by the booleans is an issue, which seems unlikely,&#xA;you could replace them with empty structs. In Go, an empty struct&#xA;typically doesn&amp;rsquo;t use any memory.&lt;/p&gt;</description>
    </item>
    <item>
      <title>2 patterns for a do-while loop in Go</title>
      <link>https://yourbasic.org/golang/do-while-loop/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/do-while-loop/</guid>
      <description>&lt;div class=&#34;extra-content&#34; style=&#34;margin:2em 0 0 1em; float:right;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/gopher-hula-hoop.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;There is no &lt;strong&gt;do-while loop&lt;/strong&gt; in Go.&#xA;To emulate the C/Java code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;do&lt;/b&gt; {&#xA;&#x9;work();&#xA;} &lt;b&gt;while&lt;/b&gt; (condition);&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;you may use a &lt;a href=&#34;https://yourbasic.org/golang/for-loop/&#34;&gt;for loop&lt;/a&gt; in one of these two ways:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;for&lt;/b&gt; ok := true; ok; ok = condition {&#xA;&#x9;work()&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;for&lt;/b&gt; {&#xA;&#x9;work()&#xA;&#x9;&lt;b&gt;if&lt;/b&gt; !condition {&#xA;&#x9;&#x9;&lt;b&gt;break&lt;/b&gt;&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;repeat-until-loop&#34;&gt;Repeat-until loop&lt;/h3&gt;&#xA;&lt;p&gt;To write a &lt;strong&gt;repeat-until loop&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;repeat&lt;/b&gt;&#xA;&#x9;work();&#xA;&lt;b&gt;until&lt;/b&gt; condition;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;simply change the condition in the code above to its complement:&lt;/p&gt;</description>
    </item>
    <item>
      <title>2 ways to delete an element from a slice</title>
      <link>https://yourbasic.org/golang/delete-element-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/delete-element-slice/</guid>
      <description>&lt;!-- CC0: https://www.pexels.com/photo/acid-background-blood-orange-citric-997725/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/odd-slice.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;fast-version-changes-order&#34;&gt;Fast version (changes order)&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []string{&#34;A&#34;, &#34;B&#34;, &#34;C&#34;, &#34;D&#34;, &#34;E&#34;}&#xA;i := 2&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Remove the element at index i from a.&lt;/span&gt;&#xA;a[i] = a[len(a)-1] &lt;span class=&#34;comment&#34;&gt;// Copy last element to index i.&lt;/span&gt;&#xA;a[len(a)-1] = &#34;&#34;   &lt;span class=&#34;comment&#34;&gt;// Erase last element (write zero value).&lt;/span&gt;&#xA;a = a[:len(a)-1]   &lt;span class=&#34;comment&#34;&gt;// Truncate slice.&lt;/span&gt;&#xA;&#xA;fmt.Println(a) &lt;span class=&#34;comment&#34;&gt;// [A B E D]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code copies a single element and runs in &lt;b&gt;constant time&lt;/b&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;slow-version-maintains-order&#34;&gt;Slow version (maintains order)&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []string{&#34;A&#34;, &#34;B&#34;, &#34;C&#34;, &#34;D&#34;, &#34;E&#34;}&#xA;i := 2&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Remove the element at index i from a.&lt;/span&gt;&#xA;copy(a[i:], a[i+1:]) &lt;span class=&#34;comment&#34;&gt;// Shift a[i+1:] left one index.&lt;/span&gt;&#xA;a[len(a)-1] = &#34;&#34;     &lt;span class=&#34;comment&#34;&gt;// Erase last element (write zero value).&lt;/span&gt;&#xA;a = a[:len(a)-1]     &lt;span class=&#34;comment&#34;&gt;// Truncate slice.&lt;/span&gt;&#xA;&#xA;fmt.Println(a) &lt;span class=&#34;comment&#34;&gt;// [A B D E]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code copies len(a) - i - 1 elements and runs in &lt;b&gt;linear time&lt;/b&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 dots in 4 places</title>
      <link>https://yourbasic.org/golang/three-dots-ellipsis/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/three-dots-ellipsis/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Can you name four places where three&amp;nbsp;dots (...) are used in&amp;nbsp;Go?&lt;/p&gt;&#xA;&lt;!-- CC0: http://maxpixel.freegreatpicture.com/Roll-White-Wallpaper-Fun-Dice-Game-Luck-3010247 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/four-dice.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;variadic-function-parameters&#34;&gt;Variadic function parameters&lt;/h2&gt;&#xA;&lt;p&gt;If the &lt;strong&gt;last parameter&lt;/strong&gt; of a function has type &lt;code&gt;...T&lt;/code&gt;, it can be called with any number of trailing arguments of type &lt;code&gt;T&lt;/code&gt;.&#xA;The actual type of &lt;code&gt;...T&lt;/code&gt; inside the function is &lt;code&gt;[]T&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;This example function can be called with, for instance, &lt;code&gt;Sum(1, 2, 3)&lt;/code&gt; or &lt;code&gt;Sum()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Sum(&lt;b&gt;nums ...int&lt;/b&gt;) int {&#xA;&#x9;res := 0&#xA;&#x9;for _, n := range nums {&#xA;&#x9;&#x9;res += n&#xA;&#x9;}&#xA;&#x9;return res&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;arguments-to-variadic-functions&#34;&gt;Arguments to variadic functions&lt;/h2&gt;&#xA;&lt;p&gt;You can pass a slice &lt;code&gt;s&lt;/code&gt; directly to a variadic function if you unpack it with the &lt;code&gt;s...&lt;/code&gt; notation.&#xA;In this case no new slice is created.&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 rules for efficient parallel computation</title>
      <link>https://yourbasic.org/golang/efficient-parallel-computation/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/efficient-parallel-computation/</guid>
      <description>&lt;!-- CC BY 3.0: https://github.com/shalakhin/gophericons --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/gopher-barbell.jpg&#34; style=&#34;float: right; margin:16px 0 0 10px;&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;Dividing a large compu&amp;shy;tation into work units for parallel pro&amp;shy;cessing is more of an art than a&amp;nbsp;science.&lt;/p&gt;&#xA;&lt;p&gt;Here are three rules of thumb.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Divide the work into units that take about 100μs to 1ms to compute.&lt;/em&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt; If&amp;nbsp;the work units are too small, the adminis&amp;shy;trative over&amp;shy;head&#xA;  of divi&amp;shy;ding the problem and sched&amp;shy;uling sub-problems might be too large.&lt;/li&gt;&#xA;&lt;li&gt; If the units are too big, the whole computation may have to wait for a single&#xA;  slow work item to finish.&#xA;  This slowdown can happen for many reasons, such as scheduling,&#xA;  interrupts from other processes, and unfortunate memory layout.&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;Note that the number of work units is independent of the number of&amp;nbsp;CPUs.&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Try to minimize the amount of data sharing.&lt;/em&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Concurrent writes can be very costly, particularly so if goroutines&#xA;execute on separate CPUs.&lt;/li&gt;&#xA;&lt;li&gt;Sharing data for reading is often much less of a problem.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;Strive for good locality when accessing data.&lt;/em&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If data can be kept in cache memory, data loading and storing&#xA;will be dramatically faster.&lt;/li&gt;&#xA;&lt;li&gt;Once again, this is particularly important for writing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Whatever strategies you are using, don&amp;rsquo;t forget to&#xA;&lt;a href=&#34;https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go&#34;&gt;benchmark&lt;/a&gt; and&#xA;&lt;a href=&#34;https://blog.golang.org/profiling-go-programs&#34;&gt;profile&lt;/a&gt;&#xA;your code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 simple ways to create an error</title>
      <link>https://yourbasic.org/golang/create-error/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/create-error/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/bug-animal-nature-windows-162019/ --&gt;&#xA;&lt;div style=&#34;float:right;margin:-10px 0 0 20px;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/bug-small.png&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;string-based-errors&#34;&gt;String-based errors&lt;/h2&gt;&#xA;&lt;p&gt;The standard library offers two out-of-the-box options.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;visibleLinks&#34;&gt;&lt;span class=&#34;comment&#34;&gt;// simple string-based error&lt;/span&gt;&#xA;err1 := &lt;a href=&#34;https://golang.org/pkg/errors/#New&#34;&gt;errors.New&lt;/a&gt;(&#34;math: square root of negative number&#34;)&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// with formatting&lt;/span&gt;&#xA;err2 := &lt;a href=&#34;https://golang.org/pkg/fmt/#Errorf&#34;&gt;fmt.Errorf&lt;/a&gt;(&#34;math: square root of negative number %g&#34;, x)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;custom-errors-with-data&#34;&gt;Custom errors with data&lt;/h2&gt;&#xA;&lt;p&gt;To define a custom error type, you must satisfy the predeclared &lt;code&gt;error&lt;/code&gt;&#xA;&lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type error interface {&#xA;&#x9;Error() string&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here are two examples.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type SyntaxError struct {&#xA;&#x9;Line int&#xA;&#x9;Col  int&#xA;}&#xA;&#xA;func (e *SyntaxError) Error() string {&#xA;&#x9;return fmt.Sprintf(&#34;%d:%d: syntax error&#34;, e.Line, e.Col)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;type InternalError struct {&#xA;&#x9;Path string&#xA;}&#xA;&#xA;func (e *InternalError) Error() string {&#xA;&#x9;return fmt.Sprintf(&#34;parse %v: internal error&#34;, e.Path)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If &lt;code&gt;Foo&lt;/code&gt; is a function that can return a &lt;code&gt;SyntaxError&lt;/code&gt; or an &lt;code&gt;InternalError&lt;/code&gt;, you may handle the two cases like this.&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 ways to compare slices (arrays)</title>
      <link>https://yourbasic.org/golang/compare-slices/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/compare-slices/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/61056899@N06/5751301741 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/scales.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;basic-case&#34;&gt;Basic case&lt;/h2&gt;&#xA;&lt;p&gt;In most cases, you will want to write your own code to compare the elements of two &lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;&lt;strong&gt;slices&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Equal tells whether a and b contain the same elements.&#xA;// A nil argument is equivalent to an empty slice.&#xA;func Equal(a, b []int) bool {&#xA;&#x9;if len(a) != len(b) {&#xA;&#x9;&#x9;return false&#xA;&#x9;}&#xA;&#x9;for i, v := range a {&#xA;&#x9;&#x9;if v != b[i] {&#xA;&#x9;&#x9;&#x9;return false&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;&#x9;return true&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;For &lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;&lt;strong&gt;arrays&lt;/strong&gt;&lt;/a&gt;, however, you can use the comparison operators &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;!=&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 ways to find a key in a map</title>
      <link>https://yourbasic.org/golang/check-map-contains-key/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/check-map-contains-key/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Search-To-Find-Internet-Magnifying-Glass-Cache-1013910 --&gt;&#xA;&lt;div style=&#34;float:right;&#34;&gt;&lt;img width=&#34;110px;&#34; src=&#34;https://yourbasic.org/golang/man-with-magnifying-glass.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;When you index a &lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;map&lt;/a&gt; in Go you get two return values;&#xA;the second one (which is optional) is a boolean that indicates if the key exists.&lt;/p&gt;&#xA;&lt;p&gt;If the key doesn&amp;rsquo;t exist, the first value will be the default&#xA;&lt;a href=&#34;https://yourbasic.org/golang/default-zero-value/&#34;&gt;zero value&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;check-second-return-value&#34;&gt;Check second return value&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := map[string]float64{&#34;pi&#34;: 3.14}&#xA;v, found := m[&#34;pi&#34;] &lt;span class=&#34;comment&#34;&gt;// v == 3.14  found == true&lt;/span&gt;&#xA;v, found = m[&#34;pie&#34;] &lt;span class=&#34;comment&#34;&gt;// v == 0.0   found == false&lt;/span&gt;&#xA;_, found = m[&#34;pi&#34;]  &lt;span class=&#34;comment&#34;&gt;// found == true&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;use-second-return-value-directly-in-an-if-statement&#34;&gt;Use second return value directly in an if statement&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := map[string]float64{&#34;pi&#34;: 3.14}&#xA;if v, found := m[&#34;pi&#34;]; found {&#xA;&#x9;fmt.Println(v)&#xA;}&#xA;&lt;span class=&#34;comment&#34;&gt;// Output: 3.14&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;check-for-zero-value&#34;&gt;Check for zero value&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := map[string]float64{&#34;pi&#34;: 3.14}&#xA;&#xA;v := m[&#34;pi&#34;] &lt;span class=&#34;comment&#34;&gt;// v == 3.14&lt;/span&gt;&#xA;v = m[&#34;pie&#34;] &lt;span class=&#34;comment&#34;&gt;// v == 0.0 (zero value)&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; This approach doesn&#39;t work if the zero value is a possible key.&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;further-reading&#34;&gt;Further reading&lt;/h2&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/15-men-in-16-slots-thumb.jpg&#34; title=&#34;Maps explained&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;Maps explained [code example]&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 ways to split a string into a slice</title>
      <link>https://yourbasic.org/golang/split-string-into-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/split-string-into-slice/</guid>
      <description>&lt;!-- Public domain: https://commons.wikimedia.org/wiki/File:Cherry-Cocktail-Split.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/cherry-cocktail-split.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#split-on-comma-or-other-substring&#34;&gt;Split on comma or other substring&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#split-by-whitespace-and-newline&#34;&gt;Split by whitespace and newline&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#split-on-regular-expression&#34;&gt;Split on regular expression&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;split-on-comma-or-other-substring&#34;&gt;Split on comma or other substring&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/strings/#Split&#34;&gt;&lt;code&gt;strings.Split&lt;/code&gt;&lt;/a&gt; function to split a string into its comma separated values.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;s := strings.Split(&amp;#34;a,b,c&amp;#34;, &amp;#34;,&amp;#34;)&#xA;fmt.Println(s)&#xA;// Output: [a b c]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To include the separators, use &lt;a href=&#34;https://golang.org/pkg/strings/#SplitAfter&#34;&gt;&lt;code&gt;strings.SplitAfter&lt;/code&gt;&lt;/a&gt;.&#xA;To split only the first n values, use &lt;a href=&#34;https://golang.org/pkg/strings/#SplitN&#34;&gt;&lt;code&gt;strings.SplitN&lt;/code&gt;&lt;/a&gt; and &lt;a href=&#34;https://golang.org/pkg/strings/#SplitAfterN&#34;&gt;&lt;code&gt;strings.SplitAfterN&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;You can use &lt;a href=&#34;https://yourbasic.org/golang/trim-whitespace-from-string/&#34;&gt;&lt;code&gt;strings.TrimSpace&lt;/code&gt;&lt;/a&gt;&#xA;to strip leading and trailing whitespace from the resulting strings.&lt;/p&gt;</description>
    </item>
    <item>
      <title>3 ways to trim whitespace (or other characters) from a string</title>
      <link>https://yourbasic.org/golang/trim-whitespace-from-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/trim-whitespace-from-string/</guid>
      <description>&lt;!-- Public domain: https://www.defense.gov/Photos/Photo-Gallery/igphoto/2001864620/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/trim-hair.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/strings/#TrimSpace&#34;&gt;&lt;code&gt;strings.TrimSpace&lt;/code&gt;&lt;/a&gt; function&#xA;to remove leading and trailing whitespace as defined by Unicode.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := strings.TrimSpace(&#34;\t Goodbye hair!\n &#34;)&#xA;fmt.Printf(&#34;%q&#34;, s) &lt;span class=&#34;comment&#34;&gt;// &#34;Goodbye hair!&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To remove other leading and trailing characters, use &lt;a href=&#34;https://golang.org/pkg/strings/#Trim&#34;&gt;&lt;code&gt;strings.Trim&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;To remove only the leading or the trailing characters, use &lt;a href=&#34;https://golang.org/pkg/strings/#TrimLeft&#34;&gt;&lt;code&gt;strings.TrimLeft&lt;/code&gt;&lt;/a&gt; or&#xA;&lt;a href=&#34;https://golang.org/pkg/strings/#TrimRight&#34;&gt;&lt;code&gt;strings.TrimRight&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;further-reading&#34;&gt;Further reading&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/golang/string-functions-reference-cheat-sheet/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/typewriter-thumb.png&#34; title=&#34;40+ practical string tips [cheat sheet]&#34;&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/string-functions-reference-cheat-sheet/&#34;&gt;40+ practical string tips [cheat sheet]&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>4 basic if-else statement patterns</title>
      <link>https://yourbasic.org/golang/if-else-statement/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/if-else-statement/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/ttypic/14157641862 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/fork-in-road.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basic-syntax&#34;&gt;Basic syntax&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#with-init-statement&#34;&gt;With init statement&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#nested-if-statements&#34;&gt;Nested if statements&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#ternary-operator-alternatives&#34;&gt;Ternary ? operator alternatives&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basic-syntax&#34;&gt;Basic syntax&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;if&lt;/b&gt; x &gt; max &lt;b&gt;{&lt;/b&gt;&#xA;&#x9;x = max&#xA;&lt;b&gt;}&lt;/b&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;if&lt;/b&gt; x &lt;= y &lt;b&gt;{&lt;/b&gt;&#xA;&#x9;min = x&#xA;&lt;b&gt;} else {&lt;/b&gt;&#xA;&#x9;min = y&#xA;&lt;b&gt;}&lt;/b&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;An &lt;strong&gt;if statement&lt;/strong&gt; executes one of two branches according to a boolean expression.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If the expression evaluates to true, the &lt;strong&gt;if&lt;/strong&gt; branch is executed,&lt;/li&gt;&#xA;&lt;li&gt;otherwise, if present, the &lt;strong&gt;else&lt;/strong&gt; branch is executed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;with-init-statement&#34;&gt;With init statement&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;if &lt;b&gt;x := f();&lt;/b&gt; x &lt;= y {&#xA;&#x9;return x&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The expression may be preceded by a &lt;strong&gt;simple statement&lt;/strong&gt;,&#xA;which executes before the expression is evaluated.&#xA;The &lt;strong&gt;scope&lt;/strong&gt; of &lt;code&gt;x&lt;/code&gt; is limited to the if statement.&lt;/p&gt;</description>
    </item>
    <item>
      <title>4 basic range loop (for-each) patterns</title>
      <link>https://yourbasic.org/golang/for-loop-range-array-slice-map-channel/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/for-loop-range-array-slice-map-channel/</guid>
      <description>&lt;!-- CC BY 3.0: https://github.com/shalakhin/gophericons --&gt;&#xA;&lt;div style=&#34;float:right; margin:0 20px 0 10px;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/gopher-hula-hoop.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basic-for-each-loop-slice-or-array&#34;&gt;Basic for-each loop (slice or array)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#string-iteration-runes-or-bytes&#34;&gt;String iteration: runes or bytes&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#map-iteration-keys-and-values&#34;&gt;Map iteration: keys and values&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#channel-iteration&#34;&gt;Channel iteration&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#gotchas&#34;&gt;Gotchas&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basic-for-each-loop-slice-or-array&#34;&gt;Basic for-each loop (slice or array)&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []string{&#34;Foo&#34;, &#34;Bar&#34;}&#xA;&lt;b&gt;for i, s := range a&lt;/b&gt; {&#xA;&#x9;fmt.Println(i, s)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;0 Foo&#xA;1 Bar&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&#xA;&lt;li&gt;The range expression, &lt;code&gt;a&lt;/code&gt;, is &lt;strong&gt;evaluated once&lt;/strong&gt; before beginning the loop.&lt;/li&gt;&#xA;&lt;li&gt;The iteration values are assigned to the respective iteration variables, &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;s&lt;/code&gt;,&#xA;&lt;strong&gt;as in an assignment statement&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The second iteration variable is optional.&lt;/li&gt;&#xA;&lt;li&gt;For a nil slice, the number of iterations is 0.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;string-iteration-runes-or-bytes&#34;&gt;String iteration: runes or bytes&lt;/h2&gt;&#xA;&lt;p&gt;For strings, the range loop iterates over &lt;a href=&#34;https://yourbasic.org/golang/rune/&#34;&gt;Unicode code points&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>4 iota enum examples</title>
      <link>https://yourbasic.org/golang/iota/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/iota/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/teosaurio/3392883329 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/lane-numbers.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#iota-basic-example&#34;&gt;Iota basic example&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;ul style=&#34;list-style: none; font-weight: normal;&#34;&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#start-from-one&#34;&gt;Start from one&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#skip-value&#34;&gt;Skip value&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;  &lt;li style=&#34;&#34;&gt;&lt;a href=&#34;#complete-enum-type-with-strings-best-practice&#34;&gt;Complete enum type with strings&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;ul style=&#34;list-style: none; font-weight: normal;&#34;&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#naming-convention&#34;&gt;Naming convention&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;iota-basic-example&#34;&gt;Iota basic example&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The &lt;a href=&#34;https://yourbasic.org/golang/iota/&#34;&gt;&lt;code&gt;iota&lt;/code&gt;&lt;/a&gt; keyword represents successive integer constants 0, 1, 2,…&lt;/li&gt;&#xA;&lt;li&gt;It resets to 0 whenever the word &lt;code&gt;const&lt;/code&gt; appears in the source code,&lt;/li&gt;&#xA;&lt;li&gt;and increments after each const specification.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;const (&#xA;&#x9;C0 = iota&#xA;&#x9;C1 = iota&#xA;&#x9;C2 = iota&#xA;)&#xA;fmt.Println(C0, C1, C2) &lt;span class=&#34;comment&#34;&gt;// &#34;0 1 2&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This can be simplified to&lt;/p&gt;</description>
    </item>
    <item>
      <title>5 basic for loop patterns</title>
      <link>https://yourbasic.org/golang/for-loop/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/for-loop/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A for statement is used to execute a block of code repeatedly.&lt;/p&gt;&#xA;&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:Girl_twirling_Hula_Hoop,_1958.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/hula-hoop.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#three-component-loop&#34;&gt;Three-component loop&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#while-loop&#34;&gt;While loop&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#infinite-loop&#34;&gt;Infinite loop&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#for-each-range-loop&#34;&gt;For-each range loop&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#exit-a-loop&#34;&gt;Exit a loop&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;three-component-loop&#34;&gt;Three-component loop&lt;/h2&gt;&#xA;&lt;p&gt;This version of the Go for loop works just as in C or Java.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sum := 0&#xA;&lt;b&gt;for i := 1; i &lt; 5; i++&lt;/b&gt; {&#xA;&#x9;sum += i&#xA;}&#xA;fmt.Println(sum) &lt;span class=&#34;comment&#34;&gt;// 10 (1+2+3+4)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The init statement, &lt;code&gt;i := 1&lt;/code&gt;, runs.&lt;/li&gt;&#xA;&lt;li&gt;The condition, &lt;code&gt;i &amp;lt; 5&lt;/code&gt;, is computed.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If true, the loop body runs,&lt;/li&gt;&#xA;&lt;li&gt;otherwise the loop is done.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ol start=&#34;3&#34;&gt;&#xA;&lt;li&gt;The post statement, &lt;code&gt;i++&lt;/code&gt;, runs.&lt;/li&gt;&#xA;&lt;li&gt;Back to step 2.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The scope of &lt;code&gt;i&lt;/code&gt; is limited to the loop.&lt;/p&gt;</description>
    </item>
    <item>
      <title>5 switch statement patterns</title>
      <link>https://yourbasic.org/golang/switch-statement/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/switch-statement/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/zigazou76/7858993572 --&gt;&#xA;&lt;div style=&#34;float:right; margin-top:-50px;&#34; class=&#34;extra-content&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/switch.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basic-switch-with-default&#34;&gt;Basic switch with default&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#no-condition&#34;&gt;No condition&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#case-list&#34;&gt;Case list&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#fallthrough&#34;&gt;Fallthrough&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#exit-with-break&#34;&gt;Exit with break&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#execution-order&#34;&gt;Execution order&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basic-switch-with-default&#34;&gt;Basic switch with default&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A switch statement runs the first case equal to the condition expression.&lt;/li&gt;&#xA;&lt;li&gt;The cases are evaluated from top to bottom, stopping when a case succeeds.&lt;/li&gt;&#xA;&lt;li&gt;If no case matches and there is a default case,&#xA;its statements are executed.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;switch&lt;/b&gt; time.Now().Weekday() {&#xA;&lt;b&gt;case&lt;/b&gt; time.Saturday:&#xA;&#x9;fmt.Println(&#34;Today is Saturday.&#34;)&#xA;&lt;b&gt;case&lt;/b&gt; time.Sunday:&#xA;&#x9;fmt.Println(&#34;Today is Sunday.&#34;)&#xA;&lt;b&gt;default&lt;/b&gt;:&#xA;&#x9;fmt.Println(&#34;Today is a weekday.&#34;)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Unlike C and Java, the case expressions do not need to be constants.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A basic stack (LIFO) data structure</title>
      <link>https://yourbasic.org/golang/implement-stack/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/implement-stack/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/fr/photo/1382123 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/stack-of-apples.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The idiomatic way to implement a stack data structure in Go is to use a &lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;slice&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;to push you use the built-in &lt;a href=&#34;https://yourbasic.org/golang/append-explained/&#34;&gt;append function&lt;/a&gt;, and&lt;/li&gt;&#xA;&lt;li&gt;to pop you slice off the top element.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;var stack []string&#xA;&#xA;stack = append(stack, &#34;world!&#34;) &lt;span class=&#34;comment&#34;&gt;// Push&lt;/span&gt;&#xA;stack = append(stack, &#34;Hello &#34;)&#xA;&#xA;for len(stack) &gt; 0 {&#xA;&#x9;n := len(stack) - 1 &lt;span class=&#34;comment&#34;&gt;// Top element&lt;/span&gt;&#xA;&#x9;fmt.Print(stack[n])&#xA;&#xA;&#x9;stack = stack[:n] &lt;span class=&#34;comment&#34;&gt;// Pop&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;Hello world!&lt;/pre&gt;&#xA;&lt;h2 id=&#34;performance&#34;&gt;Performance&lt;/h2&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/algorithms/amortized-time-complexity-analysis/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/pink-coins-thumb.jpg&#34; title=&#34;Amortized time complexity&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p&gt;Appending a single element to a slice takes &lt;strong&gt;constant amortized time&lt;/strong&gt;.&#xA;See &lt;a href=&#34;https://yourbasic.org/algorithms/amortized-time-complexity-analysis/&#34;&gt;Amortized time complexity&lt;/a&gt; for a detailed explanation.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A panic is an exception in Go</title>
      <link>https://yourbasic.org/golang/panic-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/panic-explained/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/recover-from-panic/&#34;&gt;Recover from a panic [best practices]&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>About</title>
      <link>https://yourbasic.org/about/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/about/</guid>
      <description>&lt;!-- Photo: &lt;a href=&#34;https://www.kth.se/profile/gummeson?l=en&#34;&gt;Christer Gummeson&lt;/a&gt; --&gt;&#xA;&lt;img src=&#34;https://yourbasic.org/res/stefan-nilsson.jpg&#34; alt=&#34;Stefan Nilsson&#34;&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If some of these articles and code examples can help you&#xA;become a better programmer, mission accomplished.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;about-me&#34;&gt;About me&lt;/h2&gt;&#xA;&lt;p&gt;My name is Stefan Nilsson.&lt;br&gt;&#xA;I&amp;rsquo;m a former CS prof. at &lt;a href=&#34;https://www.kth.se/en&#34;&gt;KTH&lt;/a&gt;.&lt;br&gt;&#xA;Here I write about algo­rithms and Go.&lt;/p&gt;&#xA;&lt;p&gt;&lt;span&gt;&lt;a href=&#34;https://github.com/korthaj&#34; title=&#34;github.com/korthaj&#34;&gt;&lt;img width=&#34;24px&#34; src=&#34;https://yourbasic.org/res/github-logo.svg&#34;&gt;&lt;/a&gt;&lt;/span&gt; &#xA;&lt;a href=&#34;https://github.com/korthaj&#34;&gt;My open-source software&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;about-you&#34;&gt;About you&lt;/h2&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/res/yourbasic-users-2018-2019-map.png&#34; title=&#34;Visits to yourbasic.org by country 2018-2019&#34;&gt;&lt;/div&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/res/yourbasic-users-2018-2019.png&#34; title=&#34;Monthly visits to yourbasic.org 2018-2019&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;From the start in early 2018 to December 2019 this site has had over a million visits from all over the world.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Access environment variables</title>
      <link>https://yourbasic.org/golang/environment-variables/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/environment-variables/</guid>
      <description>&lt;!-- CC0: https://www.pexels.com/photo/background-image-beautiful-blur-bright-414586/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/environment.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/os/#Setenv&#34;&gt;&lt;code&gt;os.Setenv&lt;/code&gt;&lt;/a&gt;,&#xA;&lt;a href=&#34;https://golang.org/pkg/os/#Getenv&#34;&gt;&lt;code&gt;os.Getenv&lt;/code&gt;&lt;/a&gt; and&#xA;&lt;a href=&#34;https://golang.org/pkg/os/#Unsetenv&#34;&gt;&lt;code&gt;os.Unsetenv&lt;/code&gt;&lt;/a&gt; functions&#xA;to access environment variables.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Printf(&#34;%q\n&#34;, &lt;b&gt;os.Getenv&lt;/b&gt;(&#34;SHELL&#34;)) &lt;span class=&#34;comment&#34;&gt;// &#34;/bin/bash&#34;&lt;/span&gt;&#xA;&#xA;&lt;b&gt;os.Unsetenv&lt;/b&gt;(&#34;SHELL&#34;)&#xA;fmt.Printf(&#34;%q\n&#34;, &lt;b&gt;os.Getenv&lt;/b&gt;(&#34;SHELL&#34;)) &lt;span class=&#34;comment&#34;&gt;// &#34;&#34;&lt;/span&gt;&#xA;&#xA;&lt;b&gt;os.Setenv&lt;/b&gt;(&#34;SHELL&#34;, &#34;/bin/dash&#34;)&#xA;fmt.Printf(&#34;%q\n&#34;, &lt;b&gt;os.Getenv&lt;/b&gt;(&#34;SHELL&#34;)) &lt;span class=&#34;comment&#34;&gt;// &#34;/bin/dash&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/os/#Environ&#34;&gt;&lt;code&gt;os.Environ&lt;/code&gt;&lt;/a&gt; function&#xA;returns a slice of &lt;code&gt;&amp;quot;key=value&amp;quot;&lt;/code&gt; strings listing all environment variables.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;skiphl&#34;&gt;for _, s := range &lt;b&gt;os.Environ&lt;/b&gt;() {&#xA;&#x9;kv := strings.SplitN(s, &#34;=&#34;, 2) &lt;span class=&#34;comment&#34;&gt;// unpacks &#34;key=value&#34;&lt;/span&gt;&#xA;&#x9;fmt.Printf(&#34;key:%q value:%q\n&#34;, kv[0], kv[1])&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;key:&amp;#34;SHELL&amp;#34; value:&amp;#34;/bin/bash&amp;#34;&#xA;key:&amp;#34;SESSION&amp;#34; value:&amp;#34;ubuntu&amp;#34;&#xA;key:&amp;#34;TERM&amp;#34; value:&amp;#34;xterm-256color&amp;#34;&#xA;key:&amp;#34;LANG&amp;#34; value:&amp;#34;en_US.UTF-8&amp;#34;&#xA;key:&amp;#34;XMODIFIERS&amp;#34; value:&amp;#34;@im=ibus&amp;#34;&#xA;…&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Access private fields with reflection</title>
      <link>https://yourbasic.org/golang/access-private-field-reflection/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/access-private-field-reflection/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;With reflection it&#39;s possible to read, &lt;em&gt;but not write&lt;/em&gt;,&#xA;unexported fields of a struct defined in another package.&lt;/p&gt;&#xA;&lt;!-- CC0: https://en.wikipedia.org/wiki/File:Head_mirror_in_use.png --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/head-mirror.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;In this example, we access the unexported field &lt;code&gt;len&lt;/code&gt; in the&#xA;&lt;code&gt;List&lt;/code&gt; struct in &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;package&lt;/a&gt; &lt;a href=&#34;https://golang.org/pkg/container/list/&#34;&gt;&lt;code&gt;container/list&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package list&#xA;&#xA;type List struct {&#xA;&#x9;root Element&#xA;&#x9;&lt;b&gt;len&lt;/b&gt;  int&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This code reads the value of &lt;code&gt;len&lt;/code&gt; with reflection.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&#xA;import (&#xA;&#x9;&#34;container/list&#34;&#xA;&#x9;&#34;fmt&#34;&#xA;&#x9;&#34;reflect&#34;&#xA;)&#xA;&#xA;func main() {&#xA;&#x9;l := list.New()&#xA;&#x9;l.PushFront(&#34;foo&#34;)&#xA;&#x9;l.PushFront(&#34;bar&#34;)&#xA;&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// Get a reflect.Value fv for the unexported field len.&lt;/span&gt;&#xA;&#x9;fv := reflect.ValueOf(l).Elem().FieldByName(&#34;&lt;b&gt;len&lt;/b&gt;&#34;)&#xA;&#x9;fmt.Println(fv.Int()) &lt;span class=&#34;comment&#34;&gt;// 2&lt;/span&gt;&#xA;&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// Try to set the value of len.&lt;/span&gt;&#xA;&#x9;fv.Set(reflect.ValueOf(3)) &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;ILLEGAL&lt;/b&gt;&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;2&#xA;panic: reflect: reflect.Value.Set using value obtained using unexported field&#xA;&#xA;goroutine 1 [running]:&#xA;reflect.flag.mustBeAssignable(0x1a2, 0x285a)&#xA;&#x9;/usr/local/go/src/reflect/value.go:225 +0x280&#xA;reflect.Value.Set(0xee2c0, 0x10444254, 0x1a2, 0xee2c0, 0x1280c0, 0x82)&#xA;&#x9;/usr/local/go/src/reflect/value.go:1345 +0x40&#xA;main.main()&#xA;&#x9;../main.go:18 +0x280&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Algorithms: What’s the problem?</title>
      <link>https://yourbasic.org/algorithms/algorithms/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/algorithms/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A good programmer describes algo&amp;shy;rithms in a form&#xA;that can be&amp;nbsp;effi&amp;shy;ciently exe&amp;shy;cuted by&amp;nbsp;ma&amp;shy;chines&#xA;and easily under&amp;shy;stood by&amp;nbsp;humans.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/en/maze-labyrinth-solution-lost-1804499/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/maze.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Algorithms and programs are pretty much the same thing –&#xA;the main difference is that we can talk about algorithms without relying&#xA;on a programming language.&#xA;An algorithm invented today will be equally as useful when&#xA;the last Java programmer has logged out.&#xA;Here is an attempt at a formal definition.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Amortized time complexity</title>
      <link>https://yourbasic.org/algorithms/amortized-time-complexity-analysis/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/amortized-time-complexity-analysis/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Amortized analysis is used for algo&amp;shy;rithms that have &lt;b&gt;expensive opera&amp;shy;tions&lt;/b&gt; that happen only&amp;nbsp;&lt;b&gt;rarely&lt;/b&gt;.&lt;/p&gt;&#xA;&lt;!-- CC0: https://www.pexels.com/photo/money-pink-coins-pig-9660/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/pink-coins.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Amortized complexity analysis is most commonly used with data structures&#xA;that have state that persists between operations.&#xA;The basic idea is that an expensive operation can alter the state so that&#xA;the worst case cannot occur again for a long time, thus amortizing its cost.&lt;/p&gt;&#xA;&lt;blockquote class=&#34;math&#34;&gt;&#xA;Let T&lt;sub&gt;1&lt;/sub&gt;, T&lt;sub&gt;2&lt;/sub&gt;,&amp;nbsp;…, T&lt;sub&gt;k&lt;/sub&gt; be the complexities&#xA;of a sequence of operations on a data structure. The &lt;b&gt;amortized complexity&lt;/b&gt;&#xA;of a single operation in this sequence is&#xA;(T&lt;sub&gt;1&lt;/sub&gt;&amp;nbsp;+&amp;nbsp;T&lt;sub&gt;2&lt;/sub&gt;&amp;nbsp;+&amp;nbsp;…+&amp;nbsp;T&lt;sub&gt;k&lt;/sub&gt;)&amp;nbsp;/&amp;nbsp;k.&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;example-a-dynamic-array&#34;&gt;Example: a dynamic array&lt;/h2&gt;&#xA;&lt;p&gt;In a &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-arrays/&#34;&gt;dynamic array&lt;/a&gt;,&#xA;elements are stored at the start of an underlying fixed array,&#xA;and the remaining positions are unused.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Anonymous functions and closures</title>
      <link>https://yourbasic.org/golang/anonymous-function-literal-lambda-closure/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/anonymous-function-literal-lambda-closure/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A function literal (or lambda) is a&amp;nbsp;function without a&amp;nbsp;name.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pxhere.com/en/photo/998132 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/anonymous-hoodie.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;In this example a &lt;strong&gt;function literal&lt;/strong&gt; is passed as the &lt;code&gt;less&lt;/code&gt; argument to the &lt;a href=&#34;https://golang.org/pkg/sort/#Slice&#34;&gt;&lt;code&gt;sort.Slice&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Slice(slice interface{}, less func(i, j int) bool)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;people := []string{&#34;Alice&#34;, &#34;Bob&#34;, &#34;Dave&#34;}&#xA;sort.Slice(people, &lt;b&gt;func(i, j int) bool {&#xA;&#x9;return len(people[i]) &lt; len(people[j])&#xA;}&lt;/b&gt;)&#xA;fmt.Println(people)&#xA;&lt;span class=&#34;comment&#34;&gt;// Output: [Bob Dave Alice]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can also use an intermediate variable.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;people := []string{&#34;Alice&#34;, &#34;Bob&#34;, &#34;Dave&#34;}&#xA;&lt;b&gt;less := func(i, j int) bool {&#xA;&#x9;return len(people[i]) &lt; len(people[j])&#xA;}&lt;/b&gt;&#xA;sort.Slice(people, &lt;b&gt;less&lt;/b&gt;)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note that the &lt;code&gt;less&lt;/code&gt; function is a &lt;strong&gt;closure&lt;/strong&gt;: it references the &lt;code&gt;people&lt;/code&gt; variable, which is declared outside the function.&lt;/p&gt;</description>
    </item>
    <item>
      <title>API design: principles and best practices</title>
      <link>https://yourbasic.org/algorithms/your-basic-api/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/your-basic-api/</guid>
      <description>&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/go.jpg&#34; alt=&#34;Finger pushing a go button&#34;&gt;&lt;/div&gt;&#xA;&lt;!-- CC0: https://pixabay.com/en/hand-finger-button-switch-start-944307/ --&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-5-commandments&#34;&gt;The 5 Commandments&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#1-tell-me-what-this-thing-is&#34;&gt;1. Tell me what this thing is&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#2-tell-me-what-it-does&#34;&gt;2. Tell me what it does&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#3-don-t-tell-me-how-it-works&#34;&gt;3. Don&#39;t tell me how it works&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#4-grant-me-the-right-to-use-it&#34;&gt;4. Grant me the right to use it&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#5-don-t-change-it&#34;&gt;5.  Don&#39;t change it&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#keep-it-simple&#34;&gt;Keep it simple&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#don-t-use-complicated-constructs-where-simple-ones-will-do&#34;&gt;Don&#39;t use complicated constructs where simple ones will do&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#don-t-use-a-lot-where-a-little-will-do&#34;&gt;Don&#39;t use a lot where a little will do&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#one-package-one-idea&#34;&gt;One package, one idea&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#just-say-no&#34;&gt;Just say no&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#math-is-simple&#34;&gt;Math is simple&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#give-it-time&#34;&gt;Give it time&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#eat-your-own-dog-food&#34;&gt;Eat your own dog food&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#show-don-t-tell&#34;&gt;Show, don&#39;t tell&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#create-tutorials&#34;&gt;Create tutorials&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#use-examples&#34;&gt;Use examples&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#tools-of-the-trade&#34;&gt;Tools of the trade&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#keep-it-consistent&#34;&gt;Keep it consistent&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#write-functions-that-need-little-and-give-much&#34;&gt;Write functions that need little and give much&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#discover-a-well-fitting-interface&#34;&gt;Discover a well-fitting interface&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#make-it-generic&#34;&gt;Make it generic&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#names-keep-them-short-and-sweet&#34;&gt;Names, keep them short and sweet&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;The aim of this text is to explore API design and try to find&#xA;strategies and rules that can help us create code libraries&#xA;that are safe, effective and easy to use.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Append text to a file</title>
      <link>https://yourbasic.org/golang/append-to-file/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/append-to-file/</guid>
      <description>&lt;p&gt;This code appends a line of text to the file &lt;code&gt;text.log&lt;/code&gt;.&#xA;It creates the file if it doesn&amp;rsquo;t already exist.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;f, err := os.OpenFile(&amp;#34;text.log&amp;#34;,&#xA;&#x9;os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)&#xA;if err != nil {&#xA;&#x9;log.Println(err)&#xA;}&#xA;defer f.Close()&#xA;if _, err := f.WriteString(&amp;#34;text to append\n&amp;#34;); err != nil {&#xA;&#x9;log.Println(err)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you&amp;rsquo;re appending text to a file for logging purposes, see &lt;a href=&#34;https://yourbasic.org/golang/log-to-file/&#34;&gt;Write log to file&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Array won’t change</title>
      <link>https://yourbasic.org/golang/gotcha-function-doesnt-change-array/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-function-doesnt-change-array/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/fr/photo/995842 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/sticky-gum-under-shoe.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does the array value stick?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Foo(a [2]int) {&#xA;&#x9;a[0] = 8&#xA;}&#xA;&#xA;func main() {&#xA;&#x9;a := [2]int{1, 2}&#xA;&#x9;Foo(a)         &lt;span class=&#34;comment&#34;&gt;// Try to change a[0].&lt;/span&gt;&#xA;&#x9;fmt.Println(a) &lt;span class=&#34;comment&#34;&gt;// Output: [1 2]&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Arrays in Go are &lt;b&gt;values&lt;/b&gt;.&lt;/li&gt;&#xA;&lt;li&gt;When you pass an array to a function, the array is copied.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you want &lt;code&gt;Foo&lt;/code&gt; to update the elements of&amp;nbsp;&lt;code&gt;a&lt;/code&gt;, &lt;em&gt;use a slice instead&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Foo(a []int) {&#xA;&#x9;if len(a) &gt; 0 {&#xA;&#x9;&#x9;a[0] = 8&#xA;&#x9;}&#xA;}&#xA;&#xA;func main() {&#xA;&#x9;a := []int{1, 2}&#xA;&#x9;Foo(a)         &lt;span class=&#34;comment&#34;&gt;// Change a[0].&lt;/span&gt;&#xA;&#x9;fmt.Println(a) &lt;span class=&#34;comment&#34;&gt;// Output: [8 2]&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;A slice does not store any data, it just describes a section of an underlying array.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Assignment to entry in nil map</title>
      <link>https://yourbasic.org/golang/gotcha-assignment-entry-nil-map/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-assignment-entry-nil-map/</guid>
      <description>&lt;!-- CC0: https://www.flickr.com/photos/nate/321938695 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/panic-face.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this program panic?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var m map[string]float64&#xA;m[&#34;pi&#34;] = 3.1416&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;panic: assignment to entry in nil map&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;You have to initialize the map using the make function (or a map literal) before you can add any elements:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := make(map[string]float64)&#xA;m[&#34;pi&#34;] = 3.1416&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;Maps explained&lt;/a&gt; for more about maps.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Big O notation: definition and examples</title>
      <link>https://yourbasic.org/algorithms/big-o-notation-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/big-o-notation-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Big O notation is a convenient way to describe how fast a function is&amp;nbsp;growing.&lt;/p&gt;&#xA;&lt;!-- CC BY 2.0: https://commons.wikimedia.org/wiki/File:Ocean_City_Ferris_Wheel.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/big-o.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;margin-top: 1em;&#34;&gt;&#xA;&lt;div style=&#34;float: left; min-width: 30%; margin-right: 2em;&#34;&gt;&#xA;  &lt;ul class=&#34;toc&#34; style=&#34;margin: 0;&#34;&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#definition&#34;&gt;Definition&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#constant-time&#34;&gt;Constant time&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#linear-time&#34;&gt;Linear time&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#quadratic-time&#34;&gt;Quadratic time&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left;&#34;&gt;&#xA;  &lt;ul class=&#34;toc&#34; style=&#34;margin: 0;&#34;&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#sloppy-notation&#34;&gt;Sloppy notation&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#omega-and-theta-notation&#34;&gt;Ω and Θ notation&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#key-takeaways&#34;&gt;Key takeaways&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;definition&#34;&gt;Definition&lt;/h2&gt;&#xA;&lt;p&gt;When we compute the &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-explained/&#34;&gt;time complexity&lt;/a&gt; T(&lt;i&gt;n&lt;/i&gt;)&#xA;of an algorithm we rarely get an exact result, just an estimate. That&amp;rsquo;s fine, in computer science we are typically&#xA;only interested in how fast T(&lt;i&gt;n&lt;/i&gt;) is growing as a function of the input size &lt;i&gt;n&lt;/i&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Binary search trees explained</title>
      <link>https://yourbasic.org/algorithms/binary-search-tree/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/binary-search-tree/</guid>
      <description>&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/tree.png&#34; class=&#34;extra-content&#34; style=&#34;float:right; margin:10px 60px 0 0;&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#binary-tree-definitions&#34;&gt;Binary tree definitions&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#binary-search-tree&#34;&gt;Binary search tree&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#example&#34;&gt;Example&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#balanced-trees-with-o-log-n-time-complexity&#34;&gt;Balanced trees with O(log n) time complexity&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#tree-algorithms&#34;&gt;Tree algorithms&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#inorder-traversal&#34;&gt;Inorder traversal&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#search&#34;&gt;Search&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#insert&#34;&gt;Insert&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;binary-tree-definitions&#34;&gt;Binary tree definitions&lt;/h2&gt;&#xA;&lt;p&gt;A &lt;b&gt;binary tree&lt;/b&gt; is a data structure most easily described by recursion.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;A &lt;b&gt;binary tree&lt;/b&gt;&#xA;&lt;ul style=&#34;margin:0.5em 0;&#34;&gt;&#xA;&lt;li&gt; is either empty,&lt;/li&gt;&#xA;&lt;li&gt; or consists of a &lt;b&gt;node&lt;/b&gt;&#xA;  (also known as the &lt;b&gt;root&lt;/b&gt; of the tree) and two subtrees,&#xA;  the left and right subtree, which are also binary trees.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A node with two empty subtrees is called a &lt;b&gt;leaf&lt;/b&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Binary search: take a sortcut [sic]</title>
      <link>https://yourbasic.org/golang/binary-search/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/binary-search/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/find-search-contains-slice/&#34;&gt;How to find an element in a slice/array&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bitmasks, bitsets and flags</title>
      <link>https://yourbasic.org/golang/bitmask-flag-set-clear/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/bitmask-flag-set-clear/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/christiaancolen/20445410340 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/bits.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;bitmask&#34;&gt;Bitmask&lt;/h2&gt;&#xA;&lt;p&gt;A bitmask is a small set of booleans, often called flags, represented by the bits in a single number.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type Bits uint8&#xA;&#xA;const (&#xA;&#x9;F0 Bits = 1 &lt;&lt; iota&#xA;&#x9;F1&#xA;&#x9;F2&#xA;)&#xA;&#xA;func Set(b, flag Bits) Bits    { return b | flag }&#xA;func Clear(b, flag Bits) Bits  { return b &amp;^ flag }&#xA;func Toggle(b, flag Bits) Bits { return b ^ flag }&#xA;func Has(b, flag Bits) bool    { return b&amp;flag != 0 }&#xA;&#xA;func main() {&#xA;&#x9;var b Bits&#xA;&#x9;b = Set(b, F0)&#xA;&#x9;b = Toggle(b, F2)&#xA;&#x9;for i, flag := range []Bits{F0, F1, F2} {&#xA;&#x9;&#x9;fmt.Println(i, Has(b, flag))&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;0 true&#xA;1 false&#xA;2 true&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;larger-bitsets&#34;&gt;Larger bitsets&lt;/h2&gt;&#xA;&lt;p&gt;To represent larger sets of bits, you may want to use a custom data structure.&#xA;The package &lt;a href=&#34;https://github.com/yourbasic/bit&#34;&gt;&lt;code&gt;github.com/yourbasic/bit&lt;/code&gt;&lt;/a&gt;&#xA;provides a bit array implementation and some utility bit functions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bitwise operators [cheat sheet]</title>
      <link>https://yourbasic.org/golang/bitwise-operator-cheat-sheet/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/bitwise-operator-cheat-sheet/</guid>
      <description>&lt;!-- Public domain: https://commons.wikimedia.org/wiki/File:Leibniz_binary_system_1697.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/Leibniz-binary-system-1697.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;font-size:smaller;&#34;&gt;Gottfried Wilhelm Leibniz, 1697&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#number-literals&#34;&gt;Number literals&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#built-in-operators&#34;&gt;Built-in operators&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#package-math-bits&#34;&gt;Package &lt;code&gt;math/bits&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#bit-manipulation-code-example&#34;&gt;Bit manipulation code example&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;number-literals&#34;&gt;Number literals&lt;/h2&gt;&#xA;&lt;p&gt;The binary number 10000&lt;sub&gt;2&lt;/sub&gt; can be written as &lt;code&gt;020&lt;/code&gt;, &lt;code&gt;16&lt;/code&gt; or &lt;code&gt;0x10&lt;/code&gt; in Go.&lt;/p&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Literal&lt;/th&gt;&#xA;      &lt;th&gt;Base&lt;/th&gt;&#xA;      &lt;th&gt;Note&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;020&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;8&lt;/td&gt;&#xA;      &lt;td&gt;Starts with&amp;nbsp;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;10&lt;/td&gt;&#xA;      &lt;td&gt;Never starts with&amp;nbsp;&lt;code&gt;0&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;0x10&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;16&lt;/td&gt;&#xA;      &lt;td&gt;Starts with&amp;nbsp;&lt;code&gt;0x&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&#xA;&lt;h2 id=&#34;built-in-operators&#34;&gt;Built-in operators&lt;/h2&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Operation&lt;/th&gt;&#xA;      &lt;th&gt;Result&lt;/th&gt;&#xA;      &lt;th&gt;Description&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;0011 &amp;amp; 0101&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;0001&lt;/td&gt;&#xA;      &lt;td&gt;Bitwise AND&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;0011 | 0101&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;0111&lt;/td&gt;&#xA;      &lt;td&gt;Bitwise OR&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;0011 ^ 0101&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;0110&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;Bitwise XOR&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;^0101&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;1010&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;Bitwise NOT (same as &lt;code&gt;1111&amp;nbsp;^&amp;nbsp;0101&lt;/code&gt;)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;0011 &amp;amp;^ 0101&lt;/code&gt;&lt;/td&gt; &#xA;      &lt;td&gt;0010&lt;/td&gt;&#xA;      &lt;td&gt;Bitclear (AND&amp;nbsp;NOT)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;00110101&amp;lt;&amp;lt;2&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;11010100&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;Left shift&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;00110101&amp;lt;&amp;lt;100&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;00000000&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;No upper limit on shift count&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;00110101&amp;gt;&amp;gt;2&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;00001101&lt;/td&gt;&#xA;      &lt;td&gt;Right shift&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The binary numbers in the examples are for explanation only.&#xA;Integer literals in Go must be specified in octal, decimal or hexadecimal.&lt;/li&gt;&#xA;&lt;li&gt;The bitwise operators take both signed and unsigned integers as input.&#xA;The right-hand side of a shift operator, however, must be an unsigned integer.&lt;/li&gt;&#xA;&lt;li&gt;Shift operators implement arithmetic shifts if the left operand is a signed integer&#xA;and logical shifts if it is an unsigned integer.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;package-math-bits&#34;&gt;Package &lt;a href=&#34;https://golang.org/pkg/math/bits/&#34;&gt;&lt;code style=&#34;font-size:90%;background-color:white;&#34;&gt;math/bits&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Operation&lt;/th&gt;&#xA;      &lt;th&gt;Result&lt;/th&gt;&#xA;      &lt;th&gt;Description&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;bits.UintSize&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;32 or 64&lt;/td&gt;&#xA;      &lt;td&gt;Size of a uint in bits&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;bits.OnesCount8(00101110)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;4&lt;/td&gt;&#xA;      &lt;td&gt;Number of one bits (population count)&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;bits.Len8(00101110)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;6&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;Bits required to represent number&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;bits.Len8(00000000)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;0&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;bits.LeadingZeros8(00101110)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;2&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;Number of leading zero bits&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;bits.LeadingZeros8(00000000)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;8&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;bits.TrailingZeros8(00101110)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;1&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;Number of trailing zero bits&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;bits.TrailingZeros8(00000000)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;8&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;bits.RotateLeft8(00101110,&amp;nbsp;3)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;01110001&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;The value rotated left by 3 bits&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;bits.RotateLeft8(00101110,&amp;nbsp;-3)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;11000101&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;The value rotated &lt;strong&gt;right&lt;/strong&gt; by 3&amp;nbsp;bits&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;bits.Reverse8(00101110)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;01110100&lt;/td&gt;&#xA;      &lt;td&gt;Bits in reversed order&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;bits.ReverseBytes16(0x00ff)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;&lt;code&gt;0xff00&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;Bytes in reversed order&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The functions operate on &lt;strong&gt;unsigned integers&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;They come in different forms that take arguments of different sizes.&#xA;For example, &lt;code&gt;Len&lt;/code&gt;, &lt;code&gt;Len8&lt;/code&gt;, &lt;code&gt;Len16&lt;/code&gt;, &lt;code&gt;Len32&lt;/code&gt;, and &lt;code&gt;Len64&lt;/code&gt; apply to the types&#xA;&lt;code&gt;uint&lt;/code&gt;, &lt;code&gt;uint8&lt;/code&gt;, &lt;code&gt;uint16&lt;/code&gt;, &lt;code&gt;uint32&lt;/code&gt;, and &lt;code&gt;uint64&lt;/code&gt;, respectively.&lt;/li&gt;&#xA;&lt;li&gt;The functions are recognized by the compiler and on most architectures&#xA;they are treated as &lt;a href=&#34;https://dave.cheney.net/2019/08/20/go-compiler-intrinsics&#34;&gt;intrinsics&lt;/a&gt; for additional performance.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;bit-manipulation-code-example&#34;&gt;Bit manipulation code example&lt;/h2&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/bitmask-flag-set-clear/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/bits-thumb.jpg&#34; title=&#34;Bitmasks, bitsets and flags&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/golang/bitmask-flag-set-clear/&#34;&gt;Bitmasks, bitsets and flags&lt;/a&gt; shows how to implement a bitmask, a small set of booleans, often called flags, represented by the bits in a single number.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Blackjack card counting risk analysis: poor gains at huge risk</title>
      <link>https://yourbasic.org/algorithms/blackjack/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/blackjack/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;It’s possible to win at blackjack by counting cards, but most&amp;nbsp;fail.&#xA;The mean is positive, but the variance is&amp;nbsp;mean.&lt;/p&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/res/cardsharps.jpg&#34; alt=&#34;Cardsharps, Caravaggio c. 1594.&#34;&gt;&lt;/div&gt;&#xA;&lt;h2&gt;Always optimal strategy&lt;/h2&gt;&#xA;&lt;p&gt;&#xA;  Always use an optimal strategy adapted to the rules of your casino.&#xA;  Here is an example&#xA;  &lt;a href=&#34;http://en.wikipedia.org/wiki/Blackjack#Blackjack_strategy&#34;&gt;blackjack strategy&lt;/a&gt;.&#xA;  Every time you deviate from the optimal strategy –&#xA;  because of hunches or fear – it depletes your funds.&#xA;&lt;/p&gt;&#xA;&lt;h2&gt;Count cards&lt;/h2&gt;&#xA;&lt;p&gt;&#xA;  If you find a casino with good rules, and if you play&#xA;  with an optimal strategy, the odds are still against you –&#xA;  but the house edge can sometimes be as low&#xA;  as&amp;nbsp;&lt;span style=&#34;font-size:90%&#34;&gt;0.5%&lt;/span&gt;.&#xA;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Blank identifier (underscore)</title>
      <link>https://yourbasic.org/golang/underscore/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/underscore/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/f-r-a-n-k/3076017847 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/ignore-this-text.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The blank identifier &lt;code&gt;_&lt;/code&gt; is an anonymous placeholder.&#xA;It may be used like any other identifier in a declaration, but it does not introduce a binding.&lt;/p&gt;&#xA;&lt;h2 id=&#34;ignore-values&#34;&gt;Ignore values&lt;/h2&gt;&#xA;&lt;p&gt;The blank identifier provides a way to ignore left-hand side values in an assignment.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;_, present := timeZone[&amp;#34;CET&amp;#34;]&#xA;&#xA;sum := 0&#xA;for _, n := range a {&#xA;&#x9;sum += n&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;import-for-side-effects&#34;&gt;Import for side effects&lt;/h2&gt;&#xA;&lt;p&gt;It can also be used to import a package solely for its side effects.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bloom filters explained</title>
      <link>https://yourbasic.org/algorithms/bloom-filter/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/bloom-filter/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A Bloom filter is a prob&amp;shy;abi&amp;shy;listic data struc&amp;shy;ture used to test set&amp;nbsp;member&amp;shy;ship.&lt;/p&gt;&#xA;&lt;!-- CC BY-SA 2.0:  https://commons.wikimedia.org/wiki/File:Neutral_density_filter_demonstration.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/neutral-density-filter-demonstration.jpg&#34; alt=&#34;Neutral density filter demonstration&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#bloom-filter-basics&#34;&gt;Bloom filter basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#example-blocking-shady-websites&#34;&gt;Example: Blocking shady websites&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#implementation&#34;&gt;Implementation&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance&#34;&gt;Performance&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;bloom-filter-basics&#34;&gt;Bloom filter basics&lt;/h2&gt;&#xA;&lt;p&gt;The Bloom filter data structure tells whether an element &lt;strong&gt;may be&lt;/strong&gt; in a set, or &lt;strong&gt;definitely isn&amp;rsquo;t&lt;/strong&gt;.&#xA;The only possible errors are &lt;strong&gt;false positives&lt;/strong&gt;: a search for a nonexistent element&#xA;can give an incorrect answer.&#xA;With more elements in the filter, the error rate increases.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Broadcast a signal on a channel</title>
      <link>https://yourbasic.org/golang/broadcast-channel/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/broadcast-channel/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;All readers receive zero&amp;nbsp;values on a closed channel.&lt;/p&gt;&#xA;&lt;!-- Public domain: https://en.wikipedia.org/wiki/File:Frances_Densmore_recording_Mountain_Chief2.jpg --&gt;&#xA;&lt;img src=&#34;https://yourbasic.org/golang/phonograph.jpg&#34;&gt;&#xA;&lt;p&gt;In this example the &lt;code&gt;Publish&lt;/code&gt; function returns a channel, which is used to broadcast a signal when a message has been published.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Print text after the given time has expired.&#xA;// When done, the wait channel is closed.&#xA;func Publish(text string, delay time.Duration) (wait &lt;-chan struct{}) {&#xA;&#x9;ch := make(chan struct{})&#xA;&#x9;go func() {&#xA;&#x9;&#x9;time.Sleep(delay)&#xA;&#x9;&#x9;fmt.Println(&#34;BREAKING NEWS:&#34;, text)&#xA;&#x9;&#x9;&lt;b&gt;close(ch)&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// Broadcast to all receivers.&lt;/span&gt;&#xA;&#x9;}()&#xA;&#x9;return ch&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Notice that we use a channel of empty structs: &lt;code&gt;struct{}&lt;/code&gt;. This clearly indicates that the channel will only be used for signalling, not for passing data.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Can’t change entries in range loop</title>
      <link>https://yourbasic.org/golang/gotcha-change-value-range/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-change-value-range/</guid>
      <description>&lt;!-- CC0: https://commons.wikimedia.org/wiki/File:Nothing_stone.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/nothing-written-in-stone.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why isn&amp;rsquo;t the slice updated in this example?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := []int{1, 1, 1}&#xA;for _, n := range s {&#xA;&#x9;n += 1&#xA;}&#xA;fmt.Println(s)&#xA;&lt;span class=&#34;comment&#34;&gt;// Output: [1 1 1]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The  range loop copies the values from the slice to a &lt;strong&gt;local variable&lt;/strong&gt; &lt;code&gt;n&lt;/code&gt;;&#xA;updating &lt;code&gt;n&lt;/code&gt; will not affect the&amp;nbsp;slice.&lt;/p&gt;&#xA;&lt;p&gt;Update the slice entries like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;s := []int{1, 1, 1}&#xA;for i := range s {&#xA;&#x9;s[i] += 1&#xA;}&#xA;fmt.Println(s)&#xA;&lt;span class=&#34;comment&#34;&gt;// Output: [2 2 2]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/for-loop-range-array-slice-map-channel/&#34;&gt;4 basic range loop (for-each) patterns&lt;/a&gt; for all about range loops in&amp;nbsp;Go.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Channels offer synchronized communication</title>
      <link>https://yourbasic.org/golang/channels-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/channels-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A&amp;nbsp;channel is a mechanism for goroutines to &lt;b&gt;synchronize execution&lt;/b&gt; and &lt;b&gt;communicate&lt;/b&gt; by passing values.&lt;/p&gt;&#xA;&lt;!-- CC BY-NC-ND 2.0: https://www.flickr.com/photos/erikjaeger/35008017/ --&gt;&#xA;&lt;img src=&#34;https://yourbasic.org/golang/sushi-conveyor-belt.jpg&#34; alt=&#34;sushi conveyor belt&#34;&gt;&#xA;&lt;p&gt;A new channel value can be made using the built-in function &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;span class=&#34;comment&#34;&gt;// unbuffered channel of ints&lt;/span&gt;&#xA;ic := make(chan int)&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// buffered channel with room for 10 strings&lt;/span&gt;&#xA;sc := make(chan string, 10)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;To send&lt;/strong&gt; a value on a channel, use &lt;code&gt;&amp;lt;-&lt;/code&gt; as a binary operator. &lt;strong&gt;To receive&lt;/strong&gt; a value on a channel, use it as a unary operator.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Check if a number is prime</title>
      <link>https://yourbasic.org/golang/check-prime/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/check-prime/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://en.wikipedia.org/wiki/File:Sacks_spiral.svg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/sacks-spiral.png&#34;&gt;&lt;/div&gt;&#xA;&lt;div&gt;&lt;em&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Ulam_spiral&#34;&gt;Sacks spiral of prime numbers&lt;/a&gt;&lt;/em&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;ints&#34;&gt;Ints&lt;/h2&gt;&#xA;&lt;p&gt;For integer types, use &lt;a href=&#34;https://golang.org/pkg/math/big/#Int.ProbablyPrime&#34;&gt;&lt;code&gt;ProbablyPrime(0)&lt;/code&gt;&lt;/a&gt; from package &lt;a href=&#34;https://golang.org/pkg/math/big/&#34;&gt;&lt;code&gt;math/big&lt;/code&gt;&lt;/a&gt;. This primality test is 100% accurate for inputs less than 2&lt;sup&gt;64&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const n = 1212121&#xA;if &lt;b&gt;big.NewInt(n).ProbablyPrime(0)&lt;/b&gt; {&#xA;&#x9;fmt.Println(n, &#34;is prime&#34;)&#xA;} else {&#xA;&#x9;fmt.Println(n, &#34;is not prime&#34;)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1212121 is prime&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;larger-numbers&#34;&gt;Larger numbers&lt;/h2&gt;&#xA;&lt;p&gt;&#xA;For larger numbers, you need to provide the desired number of tests to&#xA;&lt;a href=&#34;https://golang.org/pkg/math/big/#Int.ProbablyPrime&#34;&gt;&lt;code&gt;&lt;/code&gt;ProbablyPrime(n)&lt;/a&gt;.&#xA;For &lt;i&gt;n&lt;/i&gt;&amp;nbsp;tests, the&amp;nbsp;probability of returning true for&#xA;a randomly chosen non-prime is at most (1/4)&lt;sup&gt;&lt;i&gt;n&lt;/i&gt;&lt;/sup&gt;.&#xA;A&amp;nbsp;common choice is to use &lt;i&gt;n&lt;/i&gt;&amp;nbsp;=&amp;nbsp;20;&#xA;this gives a false positive rate 0.000,000,000,001.&#xA;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Command-line arguments and flags</title>
      <link>https://yourbasic.org/golang/command-line-arguments/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/command-line-arguments/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/tibetan-prayer-flags-flags-color-1384193/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/tibetan-prayer-flags.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/os/#pkg-variables&#34;&gt;&lt;code&gt;os.Args&lt;/code&gt;&lt;/a&gt; variable&#xA;holds the command-line arguments – starting with the program name –&#xA;which are passed to a Go program.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;if len(os.Args) != 3 {&#xA;&#x9;&#x9;fmt.Println(&#34;Usage:&#34;, os.Args[0], &#34;PATTERN&#34;, &#34;FILE&#34;)&#xA;&#x9;&#x9;return&#xA;&#x9;}&#xA;&#x9;pattern := os.Args[1]&#xA;&#x9;file := os.Args[2]&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// ...&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ go build grep.go&#xA;$ ./grep&#xA;Usage: ./grep PATTERN FILE&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;flag-parsing&#34;&gt;Flag parsing&lt;/h3&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/flag/&#34;&gt;flag&lt;/a&gt; package implements basic command-line flag parsing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Compute absolute value of an int/float</title>
      <link>https://yourbasic.org/golang/absolute-value-int-float/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/absolute-value-int-float/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Numbers-17-Metal-Numbers-On-Post-1110492 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/metal-numbers.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;integers&#34;&gt;Integers&lt;/h2&gt;&#xA;&lt;p&gt;There is no built-in abs function for integers,&#xA;but it&amp;rsquo;s simple to write your own.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;// Abs returns the absolute value of x.&#xA;func Abs(x int64) int64 {&#xA;&#x9;if x &amp;lt; 0 {&#xA;&#x9;&#x9;return -x&#xA;&#x9;}&#xA;&#x9;return x&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; The smallest value of a signed integer doesn’t have a matching positive value.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/math/#pkg-constants&#34;&gt;&lt;code&gt;math.MinInt64&lt;/code&gt;&lt;/a&gt; is -922337203685477580&lt;b&gt;8&lt;/b&gt;, but&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/math/#pkg-constants&#34;&gt;&lt;code&gt;math.MaxInt64&lt;/code&gt;&lt;/a&gt; is 922337203685477580&lt;b&gt;7&lt;/b&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Unfortunately, our &lt;code&gt;Abs&lt;/code&gt; function returns a &lt;b&gt;negative&lt;/b&gt; value in this case.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Compute max of two ints/floats</title>
      <link>https://yourbasic.org/golang/max-min-function/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/max-min-function/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://commons.wikimedia.org/wiki/File:Big_horse_and_little_horse.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/big-horse-and-little-horse.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;integers&#34;&gt;Integers&lt;/h2&gt;&#xA;&lt;p&gt;There is no built-in max or min function for integers,&#xA;but it&amp;rsquo;s simple to write your own.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Max returns the larger of x or y.&#xA;func Max(x, y int64) int64 {&#xA;&#x9;if x &lt; y {&#xA;&#x9;&#x9;return y&#xA;&#x9;}&#xA;&#x9;return x&#xA;}&#xA;&#xA;// Min returns the smaller of x or y.&#xA;func Min(x, y int64) int64 {&#xA;&#x9;if x &gt; y {&#xA;&#x9;&#x9;return y&#xA;&#x9;}&#xA;&#x9;return x&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;floats&#34;&gt;Floats&lt;/h2&gt;&#xA;&lt;p&gt;For floats, use &lt;a href=&#34;https://golang.org/pkg/math/#Max&#34;&gt;&lt;code&gt;math.Max&lt;/code&gt;&lt;/a&gt; and &lt;a href=&#34;https://golang.org/pkg/math/#Min&#34;&gt;&lt;code&gt;math.Min&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Concurrent programming</title>
      <link>https://yourbasic.org/golang/concurrent-programming/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/concurrent-programming/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;This tutorial covers the funda&amp;shy;mentals of concurrent programming with examples in&amp;nbsp;Go.&lt;/p&gt;&#xA;&lt;!-- CC BY-NC-ND 2.0: http://www.flickr.com/photos/un_photo/5853737946/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/bouncing-balls.jpg&#34; alt=&#34;bouncing balls&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Before you start, you need to know how to write basic Go programs.&#xA;If you need a refresher, the resources in this &lt;a href=&#34;https://yourbasic.org/golang/getting-started-hello-world/&#34;&gt;Go beginner’s guide&lt;/a&gt;&#xA;will help you come up to speed quickly with Go.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/golang/goroutines-explained/&#34; class=&#34;button&#34;&gt;Let’s start&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2&gt;Table of contents&lt;/h2&gt;</description>
    </item>
    <item>
      <title>Constant overflows int</title>
      <link>https://yourbasic.org/golang/gotcha-constant-overflows-int/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-constant-overflows-int/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.geograph.org.uk/more.php?id=3291499 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/reservoir-overflow.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t this code compile?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const n = 9876543210 * 9876543210&#xA;fmt.Println(n)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:2:13: constant 97546105778997104100 overflows int&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The untyped constant &lt;code&gt;n&lt;/code&gt; must be converted to a type before it can be&#xA;assigned to the &lt;code&gt;interface{}&lt;/code&gt; parameter in the call to &lt;code&gt;fmt.Println&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Println(a ...interface{})&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When the type can’t be inferred from the context, an untyped constant&#xA;is converted to a &lt;code&gt;bool&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;float64&lt;/code&gt;, &lt;code&gt;complex128&lt;/code&gt;, &lt;code&gt;string&lt;/code&gt; or &lt;code&gt;rune&lt;/code&gt;&#xA;depending of the format of the&amp;nbsp;constant.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Constructors deconstructed [best practice]</title>
      <link>https://yourbasic.org/golang/constructor-best-practice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/constructor-best-practice/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Go doesn&#39;t have explicit constructors.&#xA;The idiomatic way to set up new data structures&#xA;is to use proper &lt;b&gt;zero values&lt;/b&gt; coupled with &lt;b&gt;factory&lt;/b&gt; functions.&lt;/p&gt;&#xA;&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:Ba-zolotoe-kolco-rusi-2001-line.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/factory-conveyor-belt.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;zero-value&#34;&gt;Zero value&lt;/h2&gt;&#xA;&lt;p&gt;Try to make the default &lt;a href=&#34;https://yourbasic.org/golang/default-zero-value/&#34;&gt;zero value&lt;/a&gt; useful&#xA;and document its behavior. Sometimes this is all that&amp;rsquo;s needed.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// A StopWatch is a simple clock utility.&#xA;// Its zero value is an idle clock with 0 total time.&#xA;type StopWatch struct {&#xA;&#x9;start   time.Time&#xA;&#x9;total   time.Duration&#xA;&#x9;running bool&#xA;}&#xA;&#xA;var clock StopWatch &lt;span class=&#34;comment&#34;&gt;// Ready to use, no initialization needed.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;StopWatch&lt;/code&gt; takes advantage of the useful zero values of &lt;code&gt;time.Time&lt;/code&gt;, &lt;code&gt;time.Duration&lt;/code&gt; and &lt;code&gt;bool&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;In turn, users of &lt;code&gt;StopWatch&lt;/code&gt; can benefit from &lt;em&gt;its&lt;/em&gt; useful zero value.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;factory&#34;&gt;Factory&lt;/h2&gt;&#xA;&lt;p&gt;If the zero value doesn&amp;rsquo;t suffice,&#xA;use factory functions named &lt;code&gt;NewFoo&lt;/code&gt; or just &lt;code&gt;New&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Conversions [complete list]</title>
      <link>https://yourbasic.org/golang/conversions/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/conversions/</guid>
      <description>&lt;!-- Public domain: https://www.flickr.com/photos/usfwsnortheast/28273604424 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/butterfly.jpg&#34; width=&#34;400px&#34; alt=&#34;butterfly&#34; style=&#34;float: right;&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;float: left;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#interfaces&#34;&gt;Interfaces&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#integers&#34;&gt;Integers&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#floats&#34;&gt;Floats&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#integer-to-string&#34;&gt;Integer to string&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#strings-and-byte-slices&#34;&gt;Strings and byte slices&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#strings-and-rune-slices&#34;&gt;Strings and rune slices&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#underlying-type&#34;&gt;Underlying type&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#implicit-conversions&#34;&gt;Implicit conversions&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pointers&#34;&gt;Pointers&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;The expression &lt;code&gt;T(x)&lt;/code&gt; converts the value &lt;code&gt;x&lt;/code&gt; to the type &lt;code&gt;T&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x := 5.1&#xA;n := int(x) &lt;span class=&#34;comment&#34;&gt;// convert float to int&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The conversion rules are extensive but predictable:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;all conversions between typed expressions must be explicitly stated,&lt;/li&gt;&#xA;&lt;li&gt;illegal conversions are caught by the compiler.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Conversions to and from numbers and strings may &lt;strong&gt;change the representation&lt;/strong&gt;&#xA;and have a &lt;strong&gt;run-time cost&lt;/strong&gt;.&#xA;All other conversions only change the type but not the representation of &lt;code&gt;x&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Convert between byte array/slice and string</title>
      <link>https://yourbasic.org/golang/convert-string-to-byte-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/convert-string-to-byte-slice/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/appleboy/24407557644/in/photostream/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/gopher-brown-left-thumb.jpg&#34; style=&#34;float: right; margin-right: 30px;&#34; alt=&#34;Golang gopher&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#convert-string-to-bytes&#34;&gt;Convert string to bytes&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#convert-bytes-to-string&#34;&gt;Convert bytes to string&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance&#34;&gt;Performance&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;When you convert between a string and a byte slice (array),&#xA;you get a brand new slice that contains the same bytes as the string, and vice versa.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The conversion doesn&amp;rsquo;t change the data;&lt;/li&gt;&#xA;&lt;li&gt;the only difference is that strings are immutable, while byte slices can be modified.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If you need to manipulate the characters (runes) of a string, you may want to&#xA;convert the string to a rune slice instead.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/convert-string-to-rune-slice/&#34;&gt;Convert between rune array/slice and string&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Convert between float and string</title>
      <link>https://yourbasic.org/golang/convert-string-to-float/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/convert-string-to-float/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/jorel314/3352784321 --&gt;&#xA;&lt;pre style=&#34;font-size:50%;line-height:1em;border:0;&#34;&gt;&#xA;     3.141592653589793238462643383279&#xA;   5028841971693993751058209749445923&#xA;  07816406286208998628034825342117067&#xA;  9821    48086         5132&#xA; 823      06647        09384&#xA;46        09550        58223&#xA;17        25359        4081&#xA;          2848         1117&#xA;          4502         8410&#xA;          2701         9385&#xA;         21105        55964&#xA;         46229        48954&#xA;         9303         81964&#xA;         4288         10975&#xA;        66593         34461&#xA;       284756         48233&#xA;       78678          31652        71&#xA;      2019091         456485       66&#xA;     9234603           48610454326648&#xA;    2133936            0726024914127&#xA;    3724587             00660631558&#xA;    817488               152092096&#xA;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;string-to-float&#34;&gt;String to float&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/strconv/#ParseFloat&#34;&gt;&lt;code&gt;strconv.ParseFloat&lt;/code&gt;&lt;/a&gt; function to parse a string&#xA;as a floating-point number with the precision specified by &lt;code&gt;bitSize&lt;/code&gt;:&#xA;32 for &lt;code&gt;float32&lt;/code&gt;, or 64 for &lt;code&gt;float64&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Convert between int, int64 and string</title>
      <link>https://yourbasic.org/golang/convert-int-to-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/convert-int-to-string/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/numbers-123-1-2-3-one-of-the-two-1990109/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/numbers-1-2-3.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#int-int64-to-string&#34;&gt;int/int64 to string&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#string-to-int-int64&#34;&gt;string to int/int64&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#int-to-int64-and-back&#34;&gt;int to int64 (and back)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#general-formatting-width-indent-sign&#34;&gt;General formatting (width, indent, sign)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;intint64-to-string&#34;&gt;int/int64 to string&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/strconv/#Itoa&#34;&gt;&lt;code&gt;strconv.Itoa&lt;/code&gt;&lt;/a&gt; to convert an int to a decimal string.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := strconv.Itoa(97) &lt;span class=&#34;comment&#34;&gt;// s == &#34;97&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; In a plain &lt;a href=&#34;https://yourbasic.org/golang/conversions/&#34;&gt;conversion&lt;/a&gt;&#xA;the value is interpreted as a Unicode code point,&#xA;and the resulting string will contain the character represented by that code point, encoded in UTF-8.&#xA;&lt;pre&gt;&lt;code&gt;s := string(97) &lt;span class=&#34;comment&#34;&gt;// s == &#34;a&#34;&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/strconv/#FormatInt&#34;&gt;&lt;code&gt;strconv.FormatInt&lt;/code&gt;&lt;/a&gt;&#xA;to format an int64 in a given base.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Convert between rune array/slice and string</title>
      <link>https://yourbasic.org/golang/convert-string-to-rune-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/convert-string-to-rune-slice/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/appleboy/24407557644/in/photostream/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/gopher-brown-left-thumb.jpg&#34; style=&#34;float: right; margin-right: 30px;&#34; alt=&#34;Golang gopher&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#convert-string-to-runes&#34;&gt;Convert string to runes&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#convert-runes-to-string&#34;&gt;Convert runes to string&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance&#34;&gt;Performance&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;convert-string-to-runes&#34;&gt;Convert string to runes&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When you convert a string to a rune slice,&#xA;you get a new slice that contains the&#xA;&lt;a href=&#34;https://yourbasic.org/golang/rune/&#34;&gt;Unicode code points&lt;/a&gt; (runes) of the string.&lt;/li&gt;&#xA;&lt;li&gt;For an invalid UTF-8 sequence,&#xA;the rune value will be &lt;code&gt;0xFFFD&lt;/code&gt; for each invalid byte.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;r := &lt;b&gt;[]rune&lt;/b&gt;(&#34;ABC€&#34;)&#xA;fmt.Println(r)        &lt;span class=&#34;comment&#34;&gt;// [65 66 67 8364]&lt;/span&gt;&#xA;fmt.Printf(&#34;%U\n&#34;, r) &lt;span class=&#34;comment&#34;&gt;// [U+0041 U+0042 U+0043 U+20AC]&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You can also use a &lt;a href=&#34;https://yourbasic.org/golang/for-loop-range-array-slice-map-channel/&#34;&gt;range loop&lt;/a&gt;&#xA;to access the code points of a string.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Convert interface to string</title>
      <link>https://yourbasic.org/golang/interface-to-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/interface-to-string/</guid>
      <description>&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/fmt/#Sprintf&#34;&gt;&lt;code&gt;fmt.Sprintf&lt;/code&gt;&lt;/a&gt; to convert&#xA;an &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface value&lt;/a&gt; to a string.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;var x interface{} = &amp;#34;abc&amp;#34;&#xA;str := fmt.Sprintf(&amp;#34;%v&amp;#34;, x)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In fact, the same technique can be used to get a string representation of any data structure.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var x interface{} = []int{1, 2, 3}&#xA;str := fmt.Sprintf(&#34;%v&#34;, x)&#xA;fmt.Println(str) &lt;span class=&#34;comment&#34;&gt;// &#34;[1 2 3]&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;fmt-cheat-sheet&#34;&gt;Fmt cheat sheet&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/format-thumb.jpg&#34; title=&#34;Top fmt formatting tips&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/&#34;&gt;Top fmt formatting tips&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Convert string to int/int64</title>
      <link>https://yourbasic.org/golang/convert-string-to-int/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/convert-string-to-int/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/convert-int-to-string/&#34;&gt;Convert between int/int64 and string&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Create a new image</title>
      <link>https://yourbasic.org/golang/create-image/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/create-image/</guid>
      <description>&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/square-gopher.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/image/&#34;&gt;&lt;code&gt;image&lt;/code&gt;&lt;/a&gt;, &lt;a href=&#34;https://golang.org/pkg/image/color/&#34;&gt;&lt;code&gt;image/color&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&#34;https://golang.org/pkg/image/png/&#34;&gt;&lt;code&gt;image/png&lt;/code&gt;&lt;/a&gt; packages&#xA;to create a PNG image.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;width := 200&#xA;height := 100&#xA;&#xA;upLeft := image.Point{0, 0}&#xA;lowRight := image.Point{width, height}&#xA;&#xA;img := image.NewRGBA(image.Rectangle{upLeft, lowRight})&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Colors are defined by Red, Green, Blue, Alpha uint8 values.&lt;/span&gt;&#xA;cyan := color.RGBA{100, 200, 200, 0xff}&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Set color for each pixel.&lt;/span&gt;&#xA;for x := 0; x &lt; width; x++ {&#xA;&#x9;for y := 0; y &lt; height; y++ {&#xA;&#x9;&#x9;switch {&#xA;&#x9;&#x9;case x &lt; width/2 &amp;&amp; y &lt; height/2: &lt;span class=&#34;comment&#34;&gt;// upper left quadrant&lt;/span&gt;&#xA;&#x9;&#x9;&#x9;img.Set(x, y, cyan)&#xA;&#x9;&#x9;case x &gt;= width/2 &amp;&amp; y &gt;= height/2: &lt;span class=&#34;comment&#34;&gt;// lower right quadrant&lt;/span&gt;&#xA;&#x9;&#x9;&#x9;img.Set(x, y, color.White)&#xA;&#x9;&#x9;default:&#xA;&#x9;&#x9;&#x9;&lt;span class=&#34;comment&#34;&gt;// Use zero value.&lt;/span&gt;&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;}&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Encode as PNG.&lt;/span&gt;&#xA;f, _ := os.Create(&#34;image.png&#34;)&#xA;png.Encode(f, img)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Output (&lt;a href=&#34;https://yourbasic.org/golang/image.png&#34;&gt;image.png&lt;/a&gt;):&lt;/p&gt;</description>
    </item>
    <item>
      <title>Create a temporary file or directory</title>
      <link>https://yourbasic.org/golang/temporary-file-directory/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/temporary-file-directory/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/cjscott69/858673111 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/temporary-mailbox.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;file&#34;&gt;File&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/io/ioutil/#TempFile&#34;&gt;&lt;code&gt;ioutil.TempFile&lt;/code&gt;&lt;/a&gt; in package&#xA;&lt;a href=&#34;https://golang.org/pkg/io/ioutil/&#34;&gt;&lt;code&gt;io/ioutil&lt;/code&gt;&lt;/a&gt; to create a&#xA;&lt;strong&gt;globally unique temporary file&lt;/strong&gt;.&#xA;It’s your own job to remove the file when it’s no longer needed.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;file, err := ioutil.TempFile(&#34;dir&#34;, &#34;prefix&#34;)&#xA;if err != nil {&#xA;&#x9;log.Fatal(err)&#xA;}&#xA;defer os.Remove(file.Name())&#xA;&#xA;fmt.Println(file.Name()) &lt;span class=&#34;comment&#34;&gt;// For example &#34;dir/prefix054003078&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The call to &lt;a href=&#34;https://golang.org/pkg/io/ioutil/#TempFile&#34;&gt;&lt;code&gt;ioutil.TempFile&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;creates a new file with a name starting with &lt;code&gt;&amp;quot;prefix&amp;quot;&lt;/code&gt; in the directory &lt;code&gt;&amp;quot;dir&amp;quot;&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;opens the file for reading and writing,&lt;/li&gt;&#xA;&lt;li&gt;and returns the new &lt;a href=&#34;https://golang.org/pkg/os/#File&#34;&gt;&lt;code&gt;*os.File&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To put the new file in &lt;a href=&#34;https://golang.org/pkg/os/#TempDir&#34;&gt;&lt;code&gt;os.TempDir()&lt;/code&gt;&lt;/a&gt;,&#xA;the default directory for temporary files,&#xA;call &lt;a href=&#34;https://golang.org/pkg/io/ioutil/#TempFile&#34;&gt;&lt;code&gt;ioutil.TempFile&lt;/code&gt;&lt;/a&gt;&#xA;with an empty directory string.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Create, initialize and compare structs</title>
      <link>https://yourbasic.org/golang/structs-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/structs-explained/</guid>
      <description>&lt;!-- CC BY 2.0: https://commons.wikimedia.org/wiki/File:The_first_card_written_west_of_Cambridge_(4350624388).jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/catalog-card.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#struct-types&#34;&gt;Struct types&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#2-ways-to-create-and-initialize-a-new-struct&#34;&gt;2 ways to create and initialize a new struct&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#compare-structs&#34;&gt;Compare structs&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;struct-types&#34;&gt;Struct types&lt;/h2&gt;&#xA;&lt;p&gt;A struct is a typed collection of fields, useful for grouping data into records.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type Student struct {&#xA;&#x9;Name string&#xA;&#x9;Age  int&#xA;}&#xA;&#xA;var a Student    &lt;span class=&#34;comment&#34;&gt;// a == Student{&#34;&#34;, 0}&lt;/span&gt;&#xA;a.Name = &#34;Alice&#34; &lt;span class=&#34;comment&#34;&gt;// a == Student{&#34;Alice&#34;, 0}&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;To define a new &lt;strong&gt;struct type&lt;/strong&gt;, you list the names and types of each field.&lt;/li&gt;&#xA;&lt;li&gt;The default &lt;strong&gt;zero value&lt;/strong&gt; of a struct has all its fields zeroed.&lt;/li&gt;&#xA;&lt;li&gt;You can access individual fields with &lt;strong&gt;dot notation&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;2-ways-to-create-and-initialize-a-new-struct&#34;&gt;2 ways to create and initialize a new struct&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;b&gt;&lt;code&gt;new&lt;/code&gt;&lt;/b&gt; keyword can be used to create a new struct.&#xA;It returns a &lt;a href=&#34;https://yourbasic.org/golang/pointers-explained/&#34;&gt;pointer&lt;/a&gt; to the newly created struct.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Data races explained</title>
      <link>https://yourbasic.org/golang/data-races-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/data-races-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A&amp;nbsp;data&amp;nbsp;race happens when two goroutines access the same variable concur&amp;shy;rently, and at least one of the accesses is a&amp;nbsp;write.&lt;/p&gt;&#xA;&lt;p&gt;Data races are quite common and can be very hard to debug.&lt;/p&gt;&#xA;&lt;p&gt;This function has a data race and it’s behavior is undefined. It may, for example,&#xA;print the number 1. Try to figure out how that can happen –&#xA;one possible explanation comes after the code.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func race() {&#xA;&#x9;wait := make(chan struct{})&#xA;&#x9;n := 0&#xA;&#x9;go func() {&#xA;&#x9;&#x9;&lt;b&gt;n++&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// read, increment, write&lt;/span&gt;&#xA;&#x9;&#x9;close(wait)&#xA;&#x9;}()&#xA;&#x9;&lt;b&gt;n++&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// conflicting access&lt;/span&gt;&#xA;&#x9;&lt;-wait&#xA;&#x9;fmt.Println(n) &lt;span class=&#34;comment&#34;&gt;// Output: &amp;lt;unspecified&amp;gt;&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The two goroutines, g1 and g2, participate in a race&#xA;and there is no way to know in which order the operations will take place.&#xA;The following is one out of many possible outcomes.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Days between two dates</title>
      <link>https://yourbasic.org/golang/days-between-dates/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/days-between-dates/</guid>
      <description>&lt;!-- CC0: https://svgsilh.com/image/1927555.html --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/time-between-dates.png&#34; width=&#34;320px&#34;&gt;&lt;/div&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// The leap year 2016 had 366 days.&lt;/span&gt;&#xA;&#x9;t1 := Date(2016, 1, 1)&#xA;&#x9;t2 := Date(2017, 1, 1)&#xA;&#x9;days := t2.Sub(t1).Hours() / 24&#xA;&#x9;fmt.Println(days) &lt;span class=&#34;comment&#34;&gt;// 366&lt;/span&gt;&#xA;}&#xA;&#xA;func Date(year, month, day int) time.Time {&#xA;&#x9;return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)&#xA;}&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Days in a month</title>
      <link>https://yourbasic.org/golang/last-day-month-date/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/last-day-month-date/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/moon-sea-full-moon-mediterranean-2762111/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/full-moon.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;To compute the last day of a month, you can use the fact that &lt;a href=&#34;https://golang.org/pkg/time/#Date&#34;&gt;&lt;code&gt;time.Date&lt;/code&gt;&lt;/a&gt;&#xA;accepts values outside their usual ranges – the values are normalized during the conversion.&lt;/p&gt;&#xA;&lt;p&gt;To compute the number of days in February, look at the day before March 1.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;t := Date(2000, 3, 0) &lt;span class=&#34;comment&#34;&gt;// the day before 2000-03-01&lt;/span&gt;&#xA;&#x9;fmt.Println(t)        &lt;span class=&#34;comment&#34;&gt;// 2000-02-29 00:00:00 +0000 UTC&lt;/span&gt;&#xA;&#x9;fmt.Println(t.Day())  &lt;span class=&#34;comment&#34;&gt;// 29&lt;/span&gt;&#xA;}&#xA;&#xA;func Date(year, month, day int) time.Time {&#xA;&#x9;return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://golang.org/pkg/time/#Time.AddDate&#34;&gt;&lt;code&gt;AddDate&lt;/code&gt;&lt;/a&gt; normalizes its result in the same way.&#xA;For example, adding one month to October 31 yields December 1, the normalized form of November 31.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Default zero values for all Go types</title>
      <link>https://yourbasic.org/golang/default-zero-value/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/default-zero-value/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/g-ratphotos/3328593629 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/empty-hands.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Variables declared without an initial value are set to their&#xA;&lt;a href=&#34;https://golang.org/ref/spec#The_zero_value&#34;&gt;zero values&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; for all &lt;strong&gt;integer&lt;/strong&gt; types,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;0.0&lt;/code&gt; for &lt;strong&gt;floating point&lt;/strong&gt; numbers,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;false&lt;/code&gt; for &lt;strong&gt;booleans&lt;/strong&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt; for &lt;strong&gt;strings&lt;/strong&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nil&lt;/code&gt; for &lt;strong&gt;interfaces&lt;/strong&gt;, &lt;strong&gt;slices&lt;/strong&gt;, &lt;strong&gt;channels&lt;/strong&gt;, &lt;strong&gt;maps&lt;/strong&gt;, &lt;strong&gt;pointers&lt;/strong&gt; and &lt;strong&gt;functions&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The elements of an &lt;strong&gt;array&lt;/strong&gt; or &lt;strong&gt;struct&lt;/strong&gt; will have its fields zeroed if no value is specified.&#xA;This initialization is done recursively:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type T struct {&#xA;&#x9;n int&#xA;&#x9;f float64&#xA;&#x9;next *T&#xA;}&#xA;fmt.Println([2]T{}) &lt;span class=&#34;comment&#34;&gt;// [{0 0 &amp;lt;nil&amp;gt;} {0 0 &amp;lt;nil&amp;gt;}]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;further-reading&#34;&gt;Further reading&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/structs-explained/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/catalog-card-thumb.jpg&#34; title=&#34;Struct initialization code example&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/structs-explained/&#34;&gt;Struct initialization code example&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Defer a function call (with return value)</title>
      <link>https://yourbasic.org/golang/defer/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/defer/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/sign-direction-now-afterwards-1865303/ --&gt;&#xA;&lt;img src=&#34;https://yourbasic.org/golang/now-later-sign.jpg&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#defer-statement-basics&#34;&gt;Defer statement basics&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#order-of-execution&#34;&gt;Order of execution&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#use-func-to-return-a-value&#34;&gt;Use func to return a value&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#common-applications&#34;&gt;Common applications&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#close-a-file&#34;&gt;Close a file&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#error-handling-catch-a-panic&#34;&gt;Error handling: catch a panic&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;defer-statement-basics&#34;&gt;Defer statement basics&lt;/h2&gt;&#xA;&lt;p&gt;A &lt;code&gt;defer&lt;/code&gt; statement postpones the execution of a function&#xA;until the surrounding function returns, either normally or through a panic.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;&lt;b&gt;defer&lt;/b&gt; fmt.Println(&#34;World&#34;)&#xA;&#x9;fmt.Println(&#34;Hello&#34;)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;Hello&#xA;World&lt;/pre&gt;&#xA;&lt;p&gt;Deferred calls are executed even when the function panics:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Do you make these Go coding mistakes?</title>
      <link>https://yourbasic.org/golang/gotcha/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Man-Humor-Portable-Anger-Angry-Computer-Emotional-2822206 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/angry-man-with-computer.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;This collection of Go gotchas and pitfalls will help you find and fix similar problems in your own code.&lt;/p&gt;&#xA;&lt;p&gt;Some of the puzzles are pretty easy. To solve all 27, you have to be a ninja.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/golang/gotcha-assignment-entry-nil-map/&#34; class=&#34;button&#34;&gt;Let’s start&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;toc&#34;&gt;Go Gotchas&lt;/h2&gt;</description>
    </item>
    <item>
      <title>Dynamic programming [step-by-step example]</title>
      <link>https://yourbasic.org/algorithms/dynamic-programming-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/dynamic-programming-explained/</guid>
      <description>&lt;!-- CC BY-SA 2.0:  https://www.flickr.com/photos/gadl/604512604 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/recursive-photography.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#problem&#34;&gt;Problem&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#recursive-algorithm&#34;&gt;Recursive algorithm&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#dynamic-programming-with-memoization&#34;&gt;Dynamic programming with memoization&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#dynamic-programming-with-tabulation&#34;&gt;Dynamic programming with tabulation&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#memoization-vs-tabulation&#34;&gt;Memoization vs. tabulation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This text contains a detailed example showing how to solve&#xA;a tricky problem efficiently with recursion and&#xA;dynamic programming – either with memoization or tabulation.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A &lt;strong&gt;dynamic programming algorithm&lt;/strong&gt; solves a complex problem by dividing it into simpler subproblems,&#xA;solving each of those just once, and storing their solutions.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Memoization&lt;/strong&gt;  is an optimization technique used to speed up programs by storing&#xA;the results of expensive function calls and returning the cached result when&#xA;the same inputs occur again.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Tabulation&lt;/strong&gt; is an approach where you solve a dynamic programming problem&#xA;by first filling up a table, and then compute the solution to the original problem&#xA;based on the results in this table.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;problem&#34;&gt;Problem&lt;/h2&gt;&#xA;&lt;p&gt;You&amp;rsquo;ve just got a tube of delicious chocolates and plan to eat one piece a day –&#xA;either by picking the one on the left or the right.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Efficient string concatenation [full guide]</title>
      <link>https://yourbasic.org/golang/build-append-concatenate-strings-efficiently/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/build-append-concatenate-strings-efficiently/</guid>
      <description>&lt;!-- CC0: http://maxpixel.freegreatpicture.com/Hardhat-Clouds-Construction-Sky-Brick-Layer-Man-78113 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/bricklayer.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#clean-and-simple-string-building&#34;&gt;Clean and simple string building (fmt)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#high-performance-string-concatenation&#34;&gt;High-performance string concatenation (stringbuilder)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#before-go-1-10&#34;&gt;Before Go 1.10 (bytebuffer)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;clean-and-simple-string-building&#34;&gt;Clean and simple string building&lt;/h2&gt;&#xA;&lt;p&gt;For simple cases where performance is a non-issue,&#xA;&lt;a href=&#34;https://golang.org/pkg/fmt/#Sprintf&#34;&gt;&lt;code&gt;fmt.Sprintf&lt;/code&gt;&lt;/a&gt; is your friend.&#xA;It&amp;rsquo;s clean, simple and fairly efficient.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := fmt.Sprintf(&#34;Size: %d MB.&#34;, 85) &lt;span class=&#34;comment&#34;&gt;// s == &#34;Size: 85 MB.&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/&#34;&gt;fmt cheat sheet&lt;/a&gt;&#xA;lists the most common formatting verbs and flags.&lt;/p&gt;&#xA;&lt;h2 id=&#34;high-performance-string-concatenation&#34;&gt;High-performance string concatenation&lt;span class=&#34;quicklink&#34;&gt;&lt;a href=&#34;https://golang.org/doc/go1.10&#34; title=&#34;Go 1.10 Release Notes&#34;&gt;Go&amp;nbsp;1.10&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;p&gt;A &lt;a href=&#34;https://golang.org/pkg/strings/#Builder&#34;&gt;&lt;code&gt;strings.Builder&lt;/code&gt;&lt;/a&gt;&#xA;is used to efficiently append strings using write methods.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Enum with String function</title>
      <link>https://yourbasic.org/golang/define-enumeration-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/define-enumeration-string/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/iota/&#34;&gt;iota enum examples&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Error handling best practice</title>
      <link>https://yourbasic.org/golang/errors-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/errors-explained/</guid>
      <description>&lt;!-- CC BY 3.0: https://golang.org/doc/gopher/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/errors.png&#34; style=&#34;float: right; margin: 0 0 20px 20px;&#34; /&gt;&lt;/div&gt;&#xA;&lt;p&gt;Go has two different error-handling mechanisms:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;most functions return &lt;a href=&#34;https://yourbasic.org/golang/create-error/&#34;&gt;&lt;strong&gt;errors&lt;/strong&gt;&lt;/a&gt;;&lt;/li&gt;&#xA;&lt;li&gt;only a truly unrecoverable condition, such as an out-of-range index, produces a run-time exception,&#xA;known as a &lt;a href=&#34;https://yourbasic.org/golang/recover-from-panic/&#34;&gt;&lt;strong&gt;panic&lt;/strong&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Go’s multivalued return makes it easy to return a detailed error message&#xA;alongside the normal return value. By convention, such messages&#xA;have type &lt;code&gt;error&lt;/code&gt;, a simple built-in &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type error interface {&#xA;    Error() string&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;error-handling-example&#34;&gt;Error handling example&lt;/h3&gt;&#xA;&lt;p&gt;The &lt;code&gt;os.Open&lt;/code&gt; function returns a non-nil&#xA;&lt;code&gt;error&lt;/code&gt; value when it fails to open a file.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Escapes and multiline strings</title>
      <link>https://yourbasic.org/golang/multiline-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/multiline-string/</guid>
      <description>&lt;!-- CC0: https://commons.wikimedia.org/wiki/File:Aa_example1.png --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/ascii-art.png&#34; alt=&#34;Amiga style ASCII art&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#raw-string-literals&#34;&gt;Raw string literals&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#backtick-escape&#34;&gt;Backtick escape&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#interpreted-string-literals&#34;&gt;Interpreted string literals&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#double-quote-escape&#34;&gt;Double quote escape&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#escape-html&#34;&gt;Escape HTML&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#escape-url&#34;&gt;Escape URL&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#all-escape-characters&#34;&gt;All escape characters&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;raw-string-literals&#34;&gt;Raw string literals&lt;/h2&gt;&#xA;&lt;p&gt;Raw &lt;a href=&#34;https://golang.org/ref/spec#String_literals&#34;&gt;string literals&lt;/a&gt;, delimited by &lt;b&gt;backticks&lt;/b&gt; (back quotes),&#xA;are interpreted literally.&#xA;They can contain line breaks, and backslashes have no special meaning.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const s = `First line&#xA;Second line`&#xA;fmt.Println(s)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;First line&#xA;Second line&lt;/pre&gt;&#xA;&lt;h3 id=&#34;backtick-escape&#34;&gt;Backtick escape&lt;/h3&gt;&#xA;&lt;p&gt;It&amp;rsquo;s &lt;a href=&#34;https://github.com/golang/go/issues/24475&#34;&gt;not possible&lt;/a&gt; to include a backtick in a raw string literal,&#xA;but you can do&lt;/p&gt;</description>
    </item>
    <item>
      <title>Find current working directory</title>
      <link>https://yourbasic.org/golang/current-directory/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/current-directory/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/teemu-mantynen/3260514597/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/directions.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;current-directory&#34;&gt;Current directory&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/os/#Getwd&#34;&gt;&lt;code&gt;os.Getwd&lt;/code&gt;&lt;/a&gt; to find&#xA;the path name for the current directory.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;path, err := os.Getwd()&#xA;if err != nil {&#xA;&#x9;log.Println(err)&#xA;}&#xA;fmt.Println(path)  &lt;span class=&#34;comment&#34;&gt;// for example /home/user&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; If the current directory can be reached via multiple paths (due to symbolic links),&#xA;Getwd may return any one of them.&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;current-executable&#34;&gt;Current executable&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/os/#Executable&#34;&gt;&lt;code&gt;os.Executable&lt;/code&gt;&lt;/a&gt; to find&#xA;the path name for the executable that started the current process.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Find element in slice/array with linear or binary search</title>
      <link>https://yourbasic.org/golang/find-search-contains-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/find-search-contains-slice/</guid>
      <description>&lt;div style=&#34;float:right;margin:0 0 0 10px;&#34;&gt;&lt;img width=&#34;90px;&#34; src=&#34;https://yourbasic.org/golang/man-with-magnifying-glass.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#linear-search&#34;&gt;Linear search&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#binary-search&#34;&gt;Binary search&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-map-option&#34;&gt;The map option&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;linear-search&#34;&gt;Linear search&lt;/h2&gt;&#xA;&lt;p&gt;Go doesn&amp;rsquo;t have an out-of-the-box linear search function for &lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;slices and arrays&lt;/a&gt;.&#xA;Here are two example &lt;strong&gt;linear search&lt;/strong&gt; implemen­tations, which&#xA;you can use as templates.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Find returns the smallest index i at which x == a[i],&#xA;// or len(a) if there is no such index.&#xA;func Find(a []string, x string) int {&#xA;&#x9;for i, n := range a {&#xA;&#x9;&#x9;if x == n {&#xA;&#x9;&#x9;&#x9;return i&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;&#x9;return len(a)&#xA;}&#xA;&#xA;// Contains tells whether a contains x.&#xA;func Contains(a []string, x string) bool {&#xA;&#x9;for _, n := range a {&#xA;&#x9;&#x9;if x == n {&#xA;&#x9;&#x9;&#x9;return true&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;&#x9;return false&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;binary-search&#34;&gt;Binary search&lt;/h2&gt;&#xA;&lt;!-- CC BY 2.0: https://commons.wikimedia.org/wiki/File:The_fork_in_the_road_(2330044065).jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/fork-in-the-road.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;font-size:smaller;&#34;&gt;Binary search is faster than linear search, but only works if your data is in&amp;nbsp;order.&#xA;It&#39;s&amp;nbsp;a&amp;nbsp;sortcut. –&amp;nbsp;Dan&amp;nbsp;Bentley&lt;/div&gt;&#xA;&lt;p&gt;If the array is sorted, you can use a binary search instead.&#xA;This will be much more efficient, since binary search runs in worst-case logarithmic time,&#xA;making &lt;b&gt;&lt;em&gt;O&lt;/em&gt;(log &lt;em&gt;n&lt;/em&gt;)&lt;/b&gt; comparisons, where &lt;em&gt;n&lt;/em&gt; is the size of the slice.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Find the type of an object</title>
      <link>https://yourbasic.org/golang/find-type-of-object/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/find-type-of-object/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/sv/photos/mikroskop-lab-testning-vetenskap-2352650/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/microscope.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;use-fmt-for-a-string-type-description&#34;&gt;Use fmt for a string type description&lt;/h2&gt;&#xA;&lt;p&gt;You can use the &lt;code&gt;%T&lt;/code&gt; flag in the &lt;a href=&#34;https://golang.org/pkg/fmt/&#34;&gt;fmt&lt;/a&gt; package&#xA;to get a Go-syntax representation of the type.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var x interface{} = []int{1, 2, 3}&#xA;xType := fmt.Sprintf(&#34;%T&#34;, x)&#xA;fmt.Println(xType) &lt;span class=&#34;comment&#34;&gt;// &#34;[]int&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;(The &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/#the-empty-interface&#34;&gt;empty interface&lt;/a&gt; denoted by &lt;code&gt;interface{}&lt;/code&gt;&#xA;can hold values of any type.)&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-type-switch-lets-you-choose-between-types&#34;&gt;A type switch lets you choose between types&lt;/h2&gt;&#xA;&lt;p&gt;Use a &lt;a href=&#34;https://yourbasic.org/golang/type-assertion-switch/&#34;&gt;type switch&lt;/a&gt; to do several &lt;a href=&#34;https://yourbasic.org/golang/type-assertion-switch/&#34;&gt;type assertions&lt;/a&gt; in series.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var x interface{} = 2.3&#xA;switch v := x.(type) {&#xA;case int:&#xA;&#x9;fmt.Println(&#34;int:&#34;, v)&#xA;case float64:&#xA;&#x9;fmt.Println(&#34;float64:&#34;, v)&#xA;default:&#xA;&#x9;fmt.Println(&#34;unknown&#34;)&#xA;}&#xA;&lt;span class=&#34;comment&#34;&gt;// Output: float64: 2.3&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;reflection-gives-full-type-information&#34;&gt;Reflection gives full type information&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/reflect/&#34;&gt;reflect&lt;/a&gt; package if the options above don&amp;rsquo;t suffice.&lt;/p&gt;</description>
    </item>
    <item>
      <title>fmt.Printf formatting tutorial and cheat sheet</title>
      <link>https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/</guid>
      <description>&lt;!-- CC BY-SA 3.0: http://www.thebluediamondgallery.com/wooden-tile/f/format.html --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/format.jpg&#34; alt=&#34;Letter tiles forming the word format&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;margin-top: 1em;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#printf&#34;&gt;Printf&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#sprintf-format-without-printing&#34;&gt;Sprintf (format without printing)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#find-fmt-errors-with-vet&#34;&gt;Find fmt errors with vet&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#cheat-sheet&#34;&gt;Cheat sheet&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#default&#34;&gt;Default formats and type&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#integer&#34;&gt;Integer (indent, base, sign)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#character&#34;&gt;Character (quoted, Unicode)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#boolean&#34;&gt;Boolean (true/false)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#pointer&#34;&gt;Pointer (hex)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#float&#34;&gt;Float (indent, precision, scientific notation)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#string-or-byte-slice&#34;&gt;String or byte slice (quote, indent, hex)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#special-values&#34;&gt;Special values&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;With the Go &lt;a href=&#34;https://golang.org/pkg/fmt&#34;&gt;&lt;code&gt;fmt&lt;/code&gt;&lt;/a&gt; package&#xA;you can format numbers and strings padded with spaces or zeroes,&#xA;in different bases, and with optional quotes.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Format a time or date [complete guide]</title>
      <link>https://yourbasic.org/golang/format-parse-string-time-date-example/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/format-parse-string-time-date-example/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/rsdio/3642425935 --&gt;&#xA;&lt;div style=&#34;position:relative;&#34;&gt;&#xA;&lt;img class=&#34;extra-content&#34; src=&#34;https://yourbasic.org/golang/stopwatch.png&#34; alt=&#34;stopwatch&#34; style=&#34;float:right;&#34; /&gt;&#xA;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basic-example&#34;&gt;Basic example&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#standard-time-and-date-formats&#34;&gt;Standard time and date formats&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#layout-options&#34;&gt;Layout options&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#corner-cases&#34;&gt;Corner cases&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basic-example&#34;&gt;Basic example&lt;/h2&gt;&#xA;&lt;p&gt;Go doesn&amp;rsquo;t use yyyy-mm-dd layout to format a time.&#xA;Instead, you format a special &lt;strong&gt;layout parameter&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;code style=&#34;margin-left:2em;&#34;&gt;&lt;span style=&#34;color: green&#34;&gt;Mon Jan 2 15:04:05 MST 2006&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;the same way as the time or date should be formatted.&#xA;(This date is easier to remember when written as &lt;code&gt;&lt;span style=&#34;color: green&#34;&gt;01/02 03:04:05PM ‘06 -0700&lt;/span&gt;&lt;/code&gt;.)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const (&#xA;&#x9;&lt;span style=&#34;color: green&#34;&gt;&lt;b&gt;layoutISO = &#34;2006-01-02&#34;&lt;/b&gt;&lt;/span&gt;&#xA;&#x9;&lt;span style=&#34;color: green&#34;&gt;&lt;b&gt;layoutUS  = &#34;January 2, 2006&#34;&lt;/b&gt;&lt;/span&gt;&#xA;)&#xA;date := &#34;1999-12-31&#34;&#xA;t, _ := &lt;b&gt;time.Parse&lt;/b&gt;(&lt;span style=&#34;color: green&#34;&gt;&lt;b&gt;layoutISO&lt;/b&gt;&lt;/span&gt;, date)&#xA;fmt.Println(t)                  // &lt;span class=&#34;comment&#34;&gt;1999-12-31 00:00:00 +0000 UTC&lt;/span&gt;&#xA;fmt.Println(t.&lt;b&gt;Format&lt;/b&gt;(&lt;span style=&#34;color: green&#34;&gt;&lt;b&gt;layoutUS&lt;/b&gt;&lt;/span&gt;)) // &lt;span class=&#34;comment&#34;&gt;December 31, 1999&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The function&lt;/p&gt;</description>
    </item>
    <item>
      <title>Format byte size as kilobytes, megabytes, gigabytes, ...</title>
      <link>https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:Flash_memory_cards_size_comparison_(composite).svg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/flash-memory-cards.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;These utility functions convert a size in bytes to a human-readable string&#xA;in either SI (decimal) or IEC (binary) format.&lt;/p&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th style=&#34;text-align:right&#34;&gt;Input&lt;/th&gt;&#xA;      &lt;th style=&#34;text-align:right&#34;&gt;ByteCountSI&lt;/th&gt;&#xA;      &lt;th style=&#34;text-align:right&#34;&gt;ByteCountIEC&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;999&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;999&amp;nbsp;B&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;999&amp;nbsp;B&#34;&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;1000&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;1.0&amp;nbsp;kB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;1000&amp;nbsp;B&#34;&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;1023&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;1.0&amp;nbsp;kB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;1023&amp;nbsp;B&#34;&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;1024&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;1.0&amp;nbsp;kB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;1.0&amp;nbsp;KiB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;987,654,321&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;987.7&amp;nbsp;MB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;941.9&amp;nbsp;MiB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;math.MaxInt64&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&lt;code&gt;&#34;9.2&amp;nbsp;EB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td align=&#34;right&#34;&gt;&lt;code&gt;&#34;8.0&amp;nbsp;EiB&#34;&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;br&gt;&#xA;&lt;pre&gt;&lt;code&gt;func ByteCountSI(b int64) string {&#xA;&#x9;const unit = 1000&#xA;&#x9;if b &lt; unit {&#xA;&#x9;&#x9;return fmt.Sprintf(&#34;%d B&#34;, b)&#xA;&#x9;}&#xA;&#x9;div, exp := int64(unit), 0&#xA;&#x9;for n := b / unit; n &gt;= unit; n /= unit {&#xA;&#x9;&#x9;div *= unit&#xA;&#x9;&#x9;exp++&#xA;&#x9;}&#xA;&#x9;return fmt.Sprintf(&#34;%.1f %cB&#34;,&#xA;&#x9;&#x9;float64(b)/float64(div), &#34;kMGTPE&#34;[exp])&#xA;}&#xA;&#xA;func ByteCountIEC(b int64) string {&#xA;&#x9;const unit = 1024&#xA;&#x9;if b &lt; unit {&#xA;&#x9;&#x9;return fmt.Sprintf(&#34;%d B&#34;, b)&#xA;&#x9;}&#xA;&#x9;div, exp := int64(unit), 0&#xA;&#x9;for n := b / unit; n &gt;= unit; n /= unit {&#xA;&#x9;&#x9;div *= unit&#xA;&#x9;&#x9;exp++&#xA;&#x9;}&#xA;&#x9;return fmt.Sprintf(&#34;%.1f %ciB&#34;,&#xA;&#x9;&#x9;float64(b)/float64(div), &#34;KMGTPE&#34;[exp])&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/golang/byte-count.go&#34;&gt;byte-count.go&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Function types and values</title>
      <link>https://yourbasic.org/golang/function-pointer-type-declaration/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/function-pointer-type-declaration/</guid>
      <description>&lt;!-- CC0:  https://pixabay.com/en/math-function-symbol-icon-27248/ --&gt;&#xA;&lt;p&gt;Function types and function values can be used and passed around just like other values:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;type Operator func(x float64) float64&lt;/b&gt;&#xA;&#xA;// Map applies op to each element of a.&#xA;func Map(&lt;b&gt;op Operator&lt;/b&gt;, a []float64) []float64 {&#xA;&#x9;res := make([]float64, len(a))&#xA;&#x9;for i, x := range a {&#xA;&#x9;&#x9;res[i] = op(x)&#xA;&#x9;}&#xA;&#x9;return res&#xA;}&#xA;&#xA;func main() {&#xA;&#x9;&lt;b&gt;op := math.Abs&lt;/b&gt;&#xA;&#x9;a := []float64{1, -2}&#xA;&#x9;b := Map(&lt;b&gt;op&lt;/b&gt;, a)&#xA;&#x9;fmt.Println(b) &lt;span class=&#34;comment&#34;&gt;// [1 2]&lt;/span&gt;&#xA;&#xA;&#x9;c := Map(&lt;b&gt;func(x float64) float64 { return 10 * x }&lt;/b&gt;, b)&#xA;&#x9;fmt.Println(c) &lt;span class=&#34;comment&#34;&gt;// [10, 20]&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The second call to &lt;code&gt;Map&lt;/code&gt; uses a &lt;strong&gt;function literal&lt;/strong&gt; (or &lt;strong&gt;lambda&lt;/strong&gt;).&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/anonymous-function-literal-lambda-closure/&#34;&gt;Anonymous functions and closures&lt;/a&gt;&#xA;for more about lambdas in Go.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Functional programming in Go [case study]</title>
      <link>https://yourbasic.org/golang/your-basic-func/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/your-basic-func/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A graph implementation based entirely on functions&lt;/p&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/petersen-complement.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;&lt;em&gt;The Petersen graph and its complement&lt;/em&gt;&lt;/p&gt;&#xA;&lt;!-- *picture from [Wikipedia][wikipetersen2].* --&gt;&#xA;&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;This text is about the implementation of a Go tool based entirely on functions –&#xA;the API contains only immutable data types, and the code&#xA;is built on top of a &lt;code&gt;struct&lt;/code&gt; with five &lt;code&gt;func&lt;/code&gt; fields.&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s a tool for building &lt;strong&gt;virtual graphs&lt;/strong&gt;.&#xA;In a virtual graph no vertices or edges are stored in memory,&#xA;they are instead computed as needed.&#xA;The tool is part of a larger library of generic graph algorithms:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Generate a random string (password)</title>
      <link>https://yourbasic.org/golang/generate-random-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/generate-random-string/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/password-app-application-business-2781614/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/password-generator.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;random-string&#34;&gt;Random string&lt;/h2&gt;&#xA;&lt;p&gt;This code generates a random string of numbers and characters from the Swedish alphabet&#xA;(which includes the non-ASCII characters å, ä and ö).&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;rand.Seed(time.Now().UnixNano())&#xA;chars := []rune(&#34;ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ&#34; +&#xA;&#x9;&#34;abcdefghijklmnopqrstuvwxyzåäö&#34; +&#xA;&#x9;&#34;0123456789&#34;)&#xA;length := 8&#xA;var b strings.Builder&#xA;for i := 0; i &lt; length; i++ {&#xA;&#x9;b.WriteRune(chars[rand.Intn(len(chars))])&#xA;}&#xA;str := b.String() &lt;span class=&#34;comment&#34;&gt;// E.g. &#34;ExcbsVQs&#34;&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;strong&gt;Warning:&lt;/strong&gt; To generate a password, you should use cryptographically&#xA;secure pseudorandom numbers.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/crypto-rand-int/&#34;&gt;User-friendly access to crypto/rand&lt;/a&gt;.&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;random-string-with-restrictions&#34;&gt;Random string with restrictions&lt;/h2&gt;&#xA;&lt;p&gt;This code generates a random ASCII string with at least one digit and one special character.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Generate a unique string (UUID, GUID)</title>
      <link>https://yourbasic.org/golang/generate-uuid-guid/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/generate-uuid-guid/</guid>
      <description>&lt;!-- CC0: https://www.pexels.com/photo/finger-print-on-enter-key-of-keyboard-163017/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/fingerprint-keyboard.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;A &lt;a href=&#34;https://en.wikipedia.org/wiki/Universally_unique_identifier&#34;&gt;universally unique identifier&lt;/a&gt; (UUID), or globally unique identifier (GUID),&#xA;is a 128-bit number used to identify information.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A UUID is for practical purposes unique: the probability that it will be duplicated is very close to zero.&lt;/li&gt;&#xA;&lt;li&gt;UUIDs don&amp;rsquo;t depend on a central authority or on coordination between those generating them.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The string representation of a UUID consists of 32 hexadecimal digits displayed in 5 groups separated by hyphens.&#xA;For example:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Generate all permutations</title>
      <link>https://yourbasic.org/golang/generate-permutation-slice-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/generate-permutation-slice-string/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/mollystevens/12165359335 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/quilt.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Perm calls f with each permutation of a.&#xA;func Perm(a []rune, f func([]rune)) {&#xA;&#x9;perm(a, f, 0)&#xA;}&#xA;&#xA;// Permute the values at index i to len(a)-1.&#xA;func perm(a []rune, f func([]rune), i int) {&#xA;&#x9;if i &gt; len(a) {&#xA;&#x9;&#x9;f(a)&#xA;&#x9;&#x9;return&#xA;&#x9;}&#xA;&#x9;perm(a, f, i+1)&#xA;&#x9;for j := i + 1; j &lt; len(a); j++ {&#xA;&#x9;&#x9;a[i], a[j] = a[j], a[i]&#xA;&#x9;&#x9;perm(a, f, i+1)&#xA;&#x9;&#x9;a[i], a[j] = a[j], a[i]&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Example usage:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Generate random numbers, characters and slice elements</title>
      <link>https://yourbasic.org/golang/generate-number-random-range/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/generate-number-random-range/</guid>
      <description>&lt;!-- CC0: https://www.pexels.com/photo/dart-fun-game-shot-85642/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/dart.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin-top:1em;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#go-pseudo-random-number-basics&#34;&gt;Go pseudo-random number basics&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#several-random-sources&#34;&gt;Several random sources&lt;/a&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#integers-and-characters-in-a-given-range&#34;&gt;Integers and characters in a given range&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#number-between-a-and-b&#34;&gt;Number between a and b&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#character-between-39-a-39-and-39-z-39&#34;&gt;Character between a and z&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#random-element-from-slice&#34;&gt;Random element from slice&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;go-pseudo-random-number-basics&#34;&gt;Go pseudo-random number basics&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/math/rand/#Seed&#34;&gt;&lt;code&gt;rand.Seed&lt;/code&gt;&lt;/a&gt; and&#xA;&lt;a href=&#34;https://golang.org/pkg/math/rand/#Int63&#34;&gt;&lt;code&gt;rand.Int63&lt;/code&gt;&lt;/a&gt; functions in package&#xA;&lt;a href=&#34;https://golang.org/pkg/math/rand/&#34;&gt;&lt;code&gt;math/rand&lt;/code&gt;&lt;/a&gt;&#xA;to generate a non-negative pseudo-random number of type &lt;code&gt;int64&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;rand.Seed(time.Now().UnixNano())&#xA;n := rand.Int63() &lt;span class=&#34;comment&#34;&gt;// for example 4601851300195147788&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Similarly, &lt;a href=&#34;https://golang.org/pkg/math/rand/#Float64&#34;&gt;&lt;code&gt;rand.Float64&lt;/code&gt;&lt;/a&gt;&#xA;generates a pseudo-random float x, where 0 ≤ x &amp;lt; 1:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Generics (alternatives and workarounds)</title>
      <link>https://yourbasic.org/golang/generics/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/generics/</guid>
      <description>&lt;!-- CC BY-SA 3.0:  https://commons.wikimedia.org/wiki/File:Face_icon_bland.svg --&gt;&#xA;&lt;div&gt;&lt;img style=&#34;float:right; margin:20px 0 20px 20px&#34; src=&#34;https://yourbasic.org/golang/bland-face.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Go has some built-in generic data types, such as slices and maps,&#xA;and some generic functions, such as &lt;code&gt;append&lt;/code&gt; and &lt;code&gt;copy&lt;/code&gt;.&#xA;However, there is no mechanism for writing your own.&lt;/p&gt;&#xA;&lt;p&gt;Here are some techniques that can be used in place of parametric polymorphism in Go.&lt;/p&gt;&#xA;&lt;h2 id=&#34;find-a-well-fitting-interface&#34;&gt;Find a well-fitting interface&lt;/h2&gt;&#xA;&lt;p&gt;Describe the generic behaviour of your data with an &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/io/#Reader&#34;&gt;&lt;code&gt;io.Reader&lt;/code&gt;&lt;/a&gt; interface,&#xA;which represents the read end of a stream of data, is a good example:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Get slices of keys and values from a map</title>
      <link>https://yourbasic.org/golang/slice-of-keys-values-from-map/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/slice-of-keys-values-from-map/</guid>
      <description>&lt;p&gt;You can use a range statement to extract slices of keys and values from&#xA;a &lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;map&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;keys := make([]keyType, 0, len(myMap))&#xA;values := make([]valueType, 0, len(myMap))&#xA;&#xA;for k, v := range myMap {&#xA;&#x9;keys = append(keys, k)&#xA;&#x9;values = append(values, v)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;further-reading&#34;&gt;Further reading&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/15-men-in-16-slots-thumb.jpg&#34; title=&#34;Maps explained&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;Maps explained [code example]&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Get year, month, day from time</title>
      <link>https://yourbasic.org/golang/day-month-year-from-time/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/day-month-year-from-time/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Save-To-List-Note-Planning-Dates-Calendar-Date-3073971 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/mark-date-calendar.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/time/#Time.Date&#34;&gt;&lt;code&gt;Date&lt;/code&gt;&lt;/a&gt; function&#xA;returns the year, month and day of a &lt;a href=&#34;https://golang.org/pkg/time/#Time&#34;&gt;&lt;code&gt;time.Time&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func (t Time) Date() (year int, month Month, day int)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;year, month, day := time.Now().Date()&#xA;fmt.Println(year, month, day)      &lt;span class=&#34;comment&#34;&gt;// For example 2009 November 10&lt;/span&gt;&#xA;fmt.Println(year, int(month), day) &lt;span class=&#34;comment&#34;&gt;// For example 2009 11 10&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can also extract the information with seperate calls:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;t := time.Now()&#xA;year := t.Year()   &lt;span class=&#34;comment&#34;&gt;// type int&lt;/span&gt;&#xA;month := t.Month() &lt;span class=&#34;comment&#34;&gt;// type time.Month&lt;/span&gt;&#xA;day := t.Day()     &lt;span class=&#34;comment&#34;&gt;// type int&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/time/#Month&#34;&gt;&lt;code&gt;time.Month&lt;/code&gt;&lt;/a&gt; type specifies a month of the year (January = 1, …).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Get your priorities right</title>
      <link>https://yourbasic.org/golang/gotcha-operator-precedence/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-operator-precedence/</guid>
      <description>&lt;!-- CC0: https://picryl.com/media/pencil-macro-red-177beb --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/red-pencil.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t this code compute the number of hours and seconds?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n := 43210 &lt;span class=&#34;comment&#34;&gt;// time in seconds&lt;/span&gt;&#xA;fmt.Println(n/60*60, &#34;hours and&#34;, n%60*60, &#34;seconds&#34;)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;43200 hours and 600 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, and &lt;code&gt;%&lt;/code&gt; operators have the same precedence&#xA;and are evaluated left to right: &lt;code&gt;n/60*60&lt;/code&gt; is the same as &lt;code&gt;(n/60)*60&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Insert a pair of parantheses to force the correct evaluation order.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;fmt.Println(n/(60*60), &#34;hours and&#34;, n%(60*60), &#34;seconds&#34;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;12 hours and 10 seconds&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Or better yet, use a constant.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Go and Pythagoras</title>
      <link>https://yourbasic.org/golang/gotcha-bitwise-operators/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-bitwise-operators/</guid>
      <description>&lt;!-- Public domain: https://en.wikipedia.org/wiki/File:Cropped_image_of_Pythagoras_from_Raphael%27s_School_of_Athens.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/pythagoras.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Pythagorean triples are integer solutions to the Pythagorean Theorem,&#xA;a&lt;sup&gt;2&lt;/sup&gt; + b&lt;sup&gt;2&lt;/sup&gt; = c&lt;sup&gt;2&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A well-known example is (3, 4, 5):&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Println(3^2+4^2 == 5^2) &lt;span class=&#34;comment&#34;&gt;// true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The triple (6,&amp;nbsp;8,&amp;nbsp;10) is another example, but Go doesn&#39;t seem to agree.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Println(6^2+8^2 == 10^2) &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The circumflex&amp;nbsp;&lt;code&gt;^&lt;/code&gt; denotes bitwise&amp;nbsp;XOR in&amp;nbsp;Go.&#xA;The computation written in base&amp;nbsp;2 looks like&amp;nbsp;this:&lt;/p&gt;&#xA;&lt;pre&gt;&#xA;0011 ^ 0010 == 0001   (3^2 == 1)&#xA;0100 ^ 0010 == 0110   (4^2 == 6)&#xA;0101 ^ 0010 == 0111   (5^2 == 7)&#xA;&lt;/pre&gt;&#xA;&lt;p&gt;Of course, &lt;code&gt;1 + 6 == 7&lt;/code&gt;; Go and Pythagoras agree on that.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/bitwise-operator-cheat-sheet/&#34;&gt;Bitwise operators cheat sheet&lt;/a&gt; for more about bitwise calculations in&amp;nbsp;Go.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Go as a scripting language: lightweight, safe and fast</title>
      <link>https://yourbasic.org/golang/write-command-line-application/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/write-command-line-application/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:HP-HP2624B-Terminal_11.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/hp-terminal.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;This example is a simplified version of the Unix &lt;code&gt;grep&lt;/code&gt; command.&#xA;The program searches the input file for lines containing the given pattern and prints these lines.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;log.SetPrefix(&#34;grep: &#34;)&#xA;&#x9;log.SetFlags(0) &lt;span class=&#34;comment&#34;&gt;// no extra info in log messages&lt;/span&gt;&#xA;&#xA;&#x9;if len(os.Args) != 3 {&#xA;&#x9;&#x9;fmt.Printf(&#34;Usage: %v PATTERN FILE\n&#34;, os.Args[0])&#xA;&#x9;&#x9;return&#xA;&#x9;}&#xA;&#xA;&#x9;pattern, err := regexp.Compile(os.Args[1])&#xA;&#x9;if err != nil {&#xA;&#x9;&#x9;log.Fatalln(err)&#xA;&#x9;}&#xA;&#xA;&#x9;file, err := os.Open(os.Args[2])&#xA;&#x9;if err != nil {&#xA;&#x9;&#x9;log.Fatalln(err)&#xA;&#x9;}&#xA;&#x9;defer file.Close()&#xA;&#xA;&#x9;scanner := bufio.NewScanner(file)&#xA;&#x9;for scanner.Scan() {&#xA;&#x9;&#x9;line := scanner.Text()&#xA;&#x9;&#x9;if pattern.MatchString(line) {&#xA;&#x9;&#x9;&#x9;fmt.Println(line)&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;&#x9;if err := scanner.Err(); err != nil {&#xA;&#x9;&#x9;log.Println(err)&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Go beginner’s guide: top 4 resources to get you started</title>
      <link>https://yourbasic.org/golang/getting-started-hello-world/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/getting-started-hello-world/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/olpc/2606362543/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/student.jpg&#34; alt=&#34;Completely focused student in Ulaanbaatar&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;code-in-go-try-it-out&#34;&gt;Code in Go (try it out)&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://play.golang.org&#34;&gt;The Go Playground&lt;/a&gt; is an interactive web service&#xA;that lets you run small Go programs, such as this &amp;ldquo;Hello, world!&amp;rdquo; program,&#xA;inside a sandbox. Try it out!&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&#xA;import &#34;fmt&#34;&#xA;&#xA;func main() {&#xA;&#x9;fmt.Println(&#34;Hello, world!&#34;)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;learn-go-basics&#34;&gt;Learn Go basics&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://tour.golang.org/welcome/1&#34;&gt;A Tour of Go&lt;/a&gt;&#xA;is an interactive tutorial with many example programs.&#xA;It comes from the &lt;a href=&#34;https://golang.org/&#34;&gt;official golang site&lt;/a&gt;&#xA;and teaches you the basics of Go programming directly in your browser.&#xA;Try it out, it&amp;rsquo;s fun!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Go blueprints: code for common tasks</title>
      <link>https://yourbasic.org/golang/blueprint/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/blueprint/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/communication-technology-blueprint-3104305/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/blueprint.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;These code examples are intended to help you&#xA;quickly solve some common everyday tasks in Go.&#xA;There are also a few oddities that may be nice to have&#xA;when writing more exotic code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Go operator precedence spells MACAO</title>
      <link>https://yourbasic.org/golang/operator-priority/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/operator-priority/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/operators/&#34;&gt;Operators: complete list&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Go step by step</title>
      <link>https://yourbasic.org/golang/nutshells/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/nutshells/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Detailed descriptions of core Go concepts&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/photos/steps-staircase-climbing-1081909/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em; margin-bottom:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/step-by-step.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;table-of-contents&#34;&gt;Table of contents&lt;/h2&gt;</description>
    </item>
    <item>
      <title>Go string handling overview [cheat sheet]</title>
      <link>https://yourbasic.org/golang/string-functions-reference-cheat-sheet/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/string-functions-reference-cheat-sheet/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/typewriter-old-letters-print-keys-1505997/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/typewriter.png&#34; class=&#34;extra-content&#34; style=&#34;float:right;margin-top:2em;&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#string-literals-escape-characters&#34;&gt;String literals (escape characters)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#concatenate&#34;&gt;Concatenate&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#equal-and-compare-ignore-case&#34;&gt;Equal and compare (ignore case)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#length-in-bytes-or-runes&#34;&gt;Length in bytes or runes&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#index-substring-iterate&#34;&gt;Index, substring, iterate&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#search-contains-prefix-suffix-index&#34;&gt;Search (contains, prefix/suffix, index)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#replace-uppercase-lowercase-trim&#34;&gt;Replace (uppercase/lowercase, trim)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#split-by-space-or-comma&#34;&gt;Split by space or comma&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#join-strings-with-separator&#34;&gt;Join strings with separator&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#format-and-convert&#34;&gt;Format and convert&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#regular-expressions&#34;&gt;Regular expressions&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;string-literals-escape-characters&#34;&gt;String literals (escape characters)&lt;/h2&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Expression&lt;/th&gt;&#xA;      &lt;th&gt;Result&lt;/th&gt;&#xA;      &lt;th&gt;Note&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;&#34;&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt; &lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/default-zero-value/&#34;&gt;Default zero value&lt;/a&gt; for type &lt;code&gt;string&lt;/code&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;&#34;Japan 日本&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;Japan 日本&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;Go code is &lt;a href=&#34;https://yourbasic.org/golang/rune/&#34;&gt;Unicode text encoded in UTF‑8&lt;/a&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;&#34;\xe6\x97\xa5&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;日&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;\xNN&lt;/code&gt; specifies a byte&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&lt;code&gt;&#34;\u65E5&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;日&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&lt;code&gt;\uNNNN&lt;/code&gt; specifies a Unicode value&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&lt;code&gt;&#34;\\&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;\&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;Backslash&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&lt;code&gt;&#34;\&#34;&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&#34;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;Double quote&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&lt;code&gt;&#34;\n&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0; padding-top: 0;&#34;&gt;Newline&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;&#34;\t&#34;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;Tab&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;`\xe6`&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;\xe6&lt;/td&gt;&#xA;      &lt;td&gt;Raw string literal*&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;html.EscapeString(&#34;&lt;&gt;&#34;)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;&amp;amp;lt;&amp;amp;gt;&lt;/td&gt;&#xA;      &lt;td&gt;HTML escape for &lt;, &gt;, &amp;, &#39; and &#34;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;url.PathEscape(&#34;A B&#34;)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;A%20B&lt;/td&gt;&#xA;      &lt;td&gt;URL percent-encoding &lt;span class=&#34;tag&#34;&gt;net/url&lt;/span&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;* In &lt;code&gt;``&lt;/code&gt; string literals, text is interpreted literally and&#xA;backslashes have no special meaning.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/multiline-string/&#34;&gt;Escapes and multiline strings&lt;/a&gt; for more on raw strings, escape characters and string encodings.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Go tutorials</title>
      <link>https://yourbasic.org/golang/tutorials/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/tutorials/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/617921 --&gt;&#xA;&lt;div style=&#34;margin-top:1em; margin-bottom:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/learn-to-write.jpg&#34;&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Go vs. Java: 15 main differences</title>
      <link>https://yourbasic.org/golang/go-vs-java/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/go-vs-java/</guid>
      <description>&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/java-go.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The following Java code, adapted from&#xA;&lt;a href=&#34;https://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683&#34;&gt;Effective Java&lt;/a&gt;,&#xA;implements an immutable class representing a complex number.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-java&#34;&gt;public final class Complex {&#xA;    private final double re;&#xA;    private final double im;&#xA;&#xA;    public Complex(double re, double im) {&#xA;        if (Double.isNaN(re) || Double.isNaN(im)) {&#xA;            throw new ArithmeticException();&#xA;        }&#xA;        this.re = re;&#xA;        this.im = im;&#xA;    }&#xA;&#xA;    public double realPart()      { return re; }&#xA;    public double imaginaryPart() { return im; }&#xA;&#xA;    public Complex add(Complex c) {&#xA;        return new Complex(re + c.re, im + c.im);&#xA;    }&#xA;&#xA;    @Override public boolean equals(Object o) {&#xA;        if (o == this)&#xA;            return true;&#xA;        if (!(o instanceof Complex))&#xA;            return false;&#xA;        Complex c = (Complex) o;&#xA;        return Double.compare(re, c.re) == 0 &amp;amp;&amp;amp;&#xA;               Double.compare(im, c.im) == 0;&#xA;    }&#xA;&#xA;    @Override public int hashCode() {&#xA;        int result = 17 + Double.hashCode(re);&#xA;        result = 31 * result + Double.hashCode(im);&#xA;        return result;&#xA;    }&#xA;&#xA;    @Override public String toString() {&#xA;        return &#34;(&#34; + re + (im &amp;lt; 0 ? &#34;&#34; : &#34;+&#34;) + im + &#34;i)&#34;;&#xA;    }&#xA;&#xA;    public static void main(String[] args) {&#xA;        Complex z = new Complex(1, 2);&#xA;        System.out.println(z.add(z));&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The same program written in idiomatic Go would consist of two separate &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;packages&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Goroutines are lightweight threads</title>
      <link>https://yourbasic.org/golang/goroutines-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/goroutines-explained/</guid>
      <description>&lt;!-- CC BY 3.0: https://golang.org/doc/gopher/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/plane.png&#34; width=&#34;120px&#34; style=&#34;float: right; margin: -20px 0 10px 20px;&#34; /&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;The &lt;b&gt;go&lt;/b&gt; statement runs a func&amp;shy;tion in a sepa&amp;shy;rate thread&#xA;of&amp;nbsp;execu&amp;shy;tion.&lt;/p&gt;&#xA;&lt;p&gt;You can start a new thread of execution, a goroutine, with the &lt;code&gt;go&lt;/code&gt; statement.&#xA;It runs a function in a different, newly created, goroutine.&#xA;All goroutines in a single program share the same address space.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;go&lt;/b&gt; list.Sort() &lt;span class=&#34;comment&#34;&gt;// Run list.Sort in parallel; don’t wait for it.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The following program will print &amp;ldquo;Hello from main goroutine&amp;rdquo;.&#xA;It &lt;em&gt;might&lt;/em&gt; also print &amp;ldquo;Hello from another goroutine&amp;rdquo;,&#xA;depending on which of the two goroutines finish first.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hash checksums: MD5, SHA-1, SHA-256</title>
      <link>https://yourbasic.org/golang/hash-md5-sha256-string-file/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/hash-md5-sha256-string-file/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/893775 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/computer-monitoring.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;string-checksum&#34;&gt;String checksum&lt;/h2&gt;&#xA;&lt;p&gt;To compute the hash value of a &lt;strong&gt;string&lt;/strong&gt; or &lt;strong&gt;byte slice&lt;/strong&gt;,&#xA;use the &lt;code&gt;Sum&lt;/code&gt; function from a crypto package such as&#xA;&lt;a href=&#34;https://golang.org/pkg/crypto/md5/&#34;&gt;&lt;code&gt;crypto/md5&lt;/code&gt;&lt;/a&gt;,&#xA;&lt;a href=&#34;https://golang.org/pkg/crypto/sha1/&#34;&gt;&lt;code&gt;crypto/sha1&lt;/code&gt;&lt;/a&gt;, or&#xA;&lt;a href=&#34;https://golang.org/pkg/crypto/sha256/&#34;&gt;&lt;code&gt;crypto/sha256&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := &#34;Foo&#34;&#xA;&#xA;md5 := md5.Sum([]byte(s))&#xA;sha1 := sha1.Sum([]byte(s))&#xA;sha256 := sha256.Sum256([]byte(s))&#xA;&#xA;fmt.Printf(&#34;%x\n&#34;, md5)&#xA;fmt.Printf(&#34;%x\n&#34;, sha1)&#xA;fmt.Printf(&#34;%x\n&#34;, sha256)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1356c67d7ad1638d816bfb822dd2c25d&#xA;201a6b3053cc1422d2c3670b62616221d2290929&#xA;1cbec737f863e4922cee63cc2ebbfaafcd1cff8b790d8cfd2e6a5d550b648afa&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;file-checksum&#34;&gt;File checksum&lt;/h2&gt;&#xA;&lt;p&gt;To compute the hash value of a &lt;strong&gt;file&lt;/strong&gt; or other &lt;strong&gt;input stream&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;create a new &lt;a href=&#34;https://golang.org/pkg/hash/#Hash&#34;&gt;&lt;code&gt;hash.Hash&lt;/code&gt;&lt;/a&gt;&#xA;from a crypto package such as&#xA;&lt;a href=&#34;https://golang.org/pkg/crypto/md5/&#34;&gt;&lt;code&gt;crypto/md5&lt;/code&gt;&lt;/a&gt;,&#xA;&lt;a href=&#34;https://golang.org/pkg/crypto/sha1/&#34;&gt;&lt;code&gt;crypto/sha1&lt;/code&gt;&lt;/a&gt;, or&#xA;&lt;a href=&#34;https://golang.org/pkg/crypto/sha256/&#34;&gt;&lt;code&gt;crypto/sha256&lt;/code&gt;&lt;/a&gt;,&lt;/li&gt;&#xA;&lt;li&gt;add data by writing to its &lt;code&gt;io.Writer&lt;/code&gt; function,&lt;/li&gt;&#xA;&lt;li&gt;extract the checksum by calling its &lt;code&gt;Sum&lt;/code&gt; function.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;input := strings.NewReader(&#34;Foo&#34;)&#xA;&#xA;hash := sha256.New()&#xA;if _, err := io.Copy(hash, input); err != nil {&#xA;&#x9;log.Fatal(err)&#xA;}&#xA;sum := hash.Sum(nil)&#xA;&#xA;fmt.Printf(&#34;%x\n&#34;, sum)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1cbec737f863e4922cee63cc2ebbfaafcd1cff8b790d8cfd2e6a5d550b648afa&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Hash tables explained [step-by-step example]</title>
      <link>https://yourbasic.org/algorithms/hash-tables-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/hash-tables-explained/</guid>
      <description>&lt;!-- Creative commons: http://www.flickr.com/photos/60in3/3059088647/ (missing) --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/file-cabinet.jpg&#34; alt=&#34;file cabinet&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#hashing-with-chaining-simplified-example&#34;&gt;Hashing with chaining (simplified example)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#realistic-hash-function-example&#34;&gt;Realistic hash function example&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#resizing-in-constant-amortized-time&#34;&gt;Resizing in constant amortized time&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;Hash tables are used to implement map and set data structures in most common programming languages.&#xA;In C++ and Java they are part of the standard libraries, while Python and Go have builtin dictionaries and maps.&lt;/p&gt;&#xA;&lt;p&gt;A hash table is an &lt;b&gt;unordered&lt;/b&gt; collection of &lt;b&gt;key-value&lt;/b&gt; pairs, where each key is &lt;b&gt;unique&lt;/b&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hello world HTTP server example</title>
      <link>https://yourbasic.org/golang/http-server-example/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/http-server-example/</guid>
      <description>&lt;h2 id=&#34;a-basic-web-server&#34;&gt;A basic web server&lt;/h2&gt;&#xA;&lt;p&gt;If you access the URL &lt;code&gt;http://localhost:8080/world&lt;/code&gt;&#xA;on a machine where the program below is running,&#xA;you will be greeted by this page.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://yourbasic.org/golang/hello-server.png&#34; alt=&#34;Web browser localhost:8080&#34; style=&#34;border:1px solid grey;&#34; /&gt;&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;package main&#xA;&#xA;import (&#xA;    &amp;#34;fmt&amp;#34;&#xA;    &amp;#34;net/http&amp;#34;&#xA;)&#xA;&#xA;func main() {&#xA;    http.HandleFunc(&amp;#34;/&amp;#34;, HelloServer)&#xA;    http.ListenAndServe(&amp;#34;:8080&amp;#34;, nil)&#xA;}&#xA;&#xA;func HelloServer(w http.ResponseWriter, r *http.Request) {&#xA;    fmt.Fprintf(w, &amp;#34;Hello, %s!&amp;#34;, r.URL.Path[1:])&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&#xA;&lt;li&gt;The call to &lt;a href=&#34;https://golang.org/pkg/net/http/#HandleFunc&#34;&gt;&lt;code&gt;http.HandleFunc&lt;/code&gt;&lt;/a&gt;&#xA;tells the &lt;a href=&#34;https://golang.org/pkg/net/http/&#34;&gt;&lt;code&gt;net.http&lt;/code&gt;&lt;/a&gt; package&#xA;to handle all requests to the web root with the &lt;code&gt;HelloServer&lt;/code&gt; function.&lt;/li&gt;&#xA;&lt;li&gt;The call to &lt;a href=&#34;https://golang.org/pkg/net/http/#ListenAndServe&#34;&gt;&lt;code&gt;http.ListenAndServe&lt;/code&gt;&lt;/a&gt;&#xA;tells the server to listen on the TCP network address &lt;code&gt;:8080&lt;/code&gt;.&#xA;This function blocks until the program is terminated.&lt;/li&gt;&#xA;&lt;li&gt;Writing to an &lt;a href=&#34;https://golang.org/pkg/net/http/#ResponseWriter&#34;&gt;&lt;code&gt;http.ResponseWriter&lt;/code&gt;&lt;/a&gt;&#xA;sends data to the HTTP client.&lt;/li&gt;&#xA;&lt;li&gt;An &lt;a href=&#34;https://golang.org/pkg/net/http/#Request&#34;&gt;&lt;code&gt;http.Request&lt;/code&gt;&lt;/a&gt; is a data structure&#xA;that represents a client HTTP request.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;r.URL.Path&lt;/code&gt; is the path component of the requested URL. In this case, &lt;code&gt;&amp;quot;/world&amp;quot;&lt;/code&gt; is&#xA;the path component of &lt;code&gt;&amp;quot;http://localhost:8080/world&amp;quot;&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;further-reading-a-complete-wiki&#34;&gt;Further reading: a complete wiki&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/doc/articles/wiki/&#34;&gt;Writing Web Applications&lt;/a&gt; tutorial&#xA;shows how to extend this small example into a complete wiki.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How does characters add up?</title>
      <link>https://yourbasic.org/golang/gotcha-concatenate-rune-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-concatenate-rune-string/</guid>
      <description>&lt;!-- CC0: https://www.pexels.com/photo/woman-holding-pen-while-using-calculator-1253591/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/calculator.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t these print statements give the same result?&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;fmt.Println(&amp;#34;H&amp;#34; + &amp;#34;i&amp;#34;)&#xA;fmt.Println(&amp;#39;H&amp;#39; + &amp;#39;i&amp;#39;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Hi&#xA;177&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The rune literals &lt;code&gt;&#39;H&#39;&lt;/code&gt; and &lt;code&gt;&#39;i&#39;&lt;/code&gt; are integer values identifying&#xA;Unicode code points: &lt;code&gt;&#39;H&#39;&lt;/code&gt; is 72 and &lt;code&gt;&#39;i&#39;&lt;/code&gt; is&amp;nbsp;105.&lt;/p&gt;&#xA;&lt;p&gt;You can turn a code point into a string with a&amp;nbsp;conversion.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;fmt.Println(string(72) + string(&#39;i&#39;))&lt;span class=&#34;comment&#34;&gt; // &#34;Hi&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can also use the &lt;a href=&#34;https://golang.org/pkg/fmt/#Sprintf&#34;&gt;&lt;code&gt;fmt.Sprintf&lt;/code&gt;&lt;/a&gt; function.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;s := fmt.Sprintf(&#34;%c%c, world!&#34;, 72, &#39;i&#39;)&#xA;fmt.Println(s)&lt;span class=&#34;comment&#34;&gt;// &#34;Hi, world!&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This &lt;a href=&#34;https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/&#34;&gt;fmt cheat sheet&lt;/a&gt;&#xA;lists the most common formatting verbs and flags.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to analyze time complexity: Count your steps</title>
      <link>https://yourbasic.org/algorithms/time-complexity-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/time-complexity-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Time complexity esti&amp;shy;mates the time to run an algo&amp;shy;rithm.&#xA;It&#39;s calcu&amp;shy;lated by counting elemen&amp;shy;tary opera&amp;shy;tions.&#xA;&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/en/slide-rule-count-math-mathematics-317759/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/abacus.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#example-iterative-algorithm&#34;&gt;Example (iterative algorithm)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#worst-case-time-complexity&#34;&gt;Worst-case time complexity&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#average-case-time-complexity&#34;&gt;Average-case time complexity&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#quadratic-time-complexity&#34;&gt;Quadratic time complexity&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;example-iterative-algorithm&#34;&gt;Example (iterative algorithm)&lt;/h2&gt;&#xA;&lt;p&gt;What&amp;rsquo;s the running time of the following algorithm?&lt;/p&gt;&#xA;&lt;pre&gt;&#xA;// Compute the maximum element in the array a.&#xA;&lt;b&gt;Algorithm&lt;/b&gt; max(a):&#xA;&#x9;max ← a[0]&#xA;&#x9;&lt;b&gt;for&lt;/b&gt; i = 1 &lt;b&gt;to&lt;/b&gt; len(a)-1&#xA;&#x9;&#x9;&lt;b&gt;if&lt;/b&gt; a[i] &amp;gt; max&#xA;&#x9;&#x9;&#x9;max ← a[i]&#xA;&#x9;&lt;b&gt;return&lt;/b&gt; max&#xA;&lt;/pre&gt;&#xA;&lt;p&gt;The answer depends on factors such as input, programming language and runtime,&#xA;coding skill, compiler, operating system, and hardware.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to append anything (element, slice or string) to a slice</title>
      <link>https://yourbasic.org/golang/append-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/append-explained/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/toddler-fiat-126p-trailer-car-456161/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/toddler-fiat-with-trailer.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#append-function-basics&#34;&gt;Append function basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#append-one-slice-to-another&#34;&gt;Append one slice to another&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#append-string-to-byte-slice&#34;&gt;Append string to byte slice&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance&#34;&gt;Performance&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;append-function-basics&#34;&gt;Append function basics&lt;/h2&gt;&#xA;&lt;p&gt;With the built-in &lt;a href=&#34;https://golang.org/ref/spec#Appending_and_copying_slices&#34;&gt;append function&lt;/a&gt;&#xA;you can use a slice as a &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-arrays/&#34;&gt;dynamic array&lt;/a&gt;.&#xA;The function appends any number of elements to the end of a &lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;slice&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if there is enough capacity, the underlying array is reused;&lt;/li&gt;&#xA;&lt;li&gt;if not, a new underlying array is allocated and the data is copied over.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Append &lt;strong&gt;returns the updated slice&lt;/strong&gt;.&#xA;Therefore you need to store the result of an append,&#xA;often in the variable holding the slice itself:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to avoid initializing memory [in theory]</title>
      <link>https://yourbasic.org/algorithms/avoid-initializing-memory/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/avoid-initializing-memory/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/blakespot/6173837649 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/ram.jpg&#34; alt=&#34;A pile of RAM memory&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Consider an algorithm that uses a large memory area.&#xA;If the running time of the algorithm is smaller than the size of the memory,&#xA;initializing the memory will take longer than running the algorithm.&#xA;However, using a shrewd trick,&#xA;it’s possible to refrain from initializing the memory.&lt;/p&gt;&#xA;&lt;p&gt;This mysterious trick is used quite frequently in research articles,&#xA;often without explanation and a reference to Exercise 2.12 in&#xA;&lt;a href=&#34;https://dl.acm.org/citation.cfm?id=578775&#34;&gt;The Design and Analysis of Computer Algorithms&lt;/a&gt;&#xA;by Aho, Hopcroft, and Ullman, 1974.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to best clear a slice: empty vs. nil</title>
      <link>https://yourbasic.org/golang/clear-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/clear-slice/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/aquamech-utah/24441624384 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/window-cleaner.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#remove-all-elements&#34;&gt;Remove all elements&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#keep-allocated-memory&#34;&gt;Keep allocated memory&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#empty-slice-vs-nil-slice&#34;&gt;Empty slice vs. nil slice&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;remove-all-elements&#34;&gt;Remove all elements&lt;/h2&gt;&#xA;&lt;p&gt;To remove all elements, simply set the slice to &lt;code&gt;nil&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []string{&#34;A&#34;, &#34;B&#34;, &#34;C&#34;, &#34;D&#34;, &#34;E&#34;}&#xA;a = nil&#xA;fmt.Println(a, len(a), cap(a)) &lt;span class=&#34;comment&#34;&gt;// [] 0 0&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This will release the underlying array to the garbage collector (assuming there are no other references).&lt;/p&gt;&#xA;&lt;h2 id=&#34;keep-allocated-memory&#34;&gt;Keep allocated memory&lt;/h2&gt;&#xA;&lt;p&gt;To keep the underlying array, slice the slice to zero length.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to best implement an iterator</title>
      <link>https://yourbasic.org/golang/iterator-generator-pattern/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/iterator-generator-pattern/</guid>
      <description>&lt;div style=&#34;float:right; margin-left:16px;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/spinning-wheel.gif&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Go has a built-in range loop for iterating over slices, arrays, strings, maps and channels.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/for-loop-range-array-slice-map-channel/&#34;&gt;4 basic range loop (for-each) patterns&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To iterate over other types of data, an iterator function with callbacks is a clean and fairly efficient abstraction.&lt;/p&gt;&#xA;&lt;h2 id=&#34;basic-iterator-pattern&#34;&gt;Basic iterator pattern&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Iterate calls the f function with n = 1, 2, and 3.&#xA;func Iterate(f func(n int)) {&#xA;&#x9;for i := 1; i &lt;= 3; i++ {&#xA;&#x9;&#x9;f(i)&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In use:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to debug deadlocks</title>
      <link>https://yourbasic.org/golang/detect-deadlock/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/detect-deadlock/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A deadlock happens when a group of goroutines are waiting for each other and none of them is able to&amp;nbsp;proceed.&lt;/p&gt;&#xA;&lt;!-- CC BY-NC 2.0: http://www.flickr.com/photos/lasgalletas/263909727/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/traffic-jam.jpg&#34; alt=&#34;traffic jam&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Take a look at this simple example.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func main() {&#xA;&#x9;ch := make(chan int)&#xA;&#x9;ch &amp;lt;- 1&#xA;&#x9;fmt.Println(&amp;lt;-ch)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The program will get stuck on the channel send operation&#xA;waiting forever for someone to read the value.&#xA;Go is able to detect situations like this at runtime.&#xA;Here is the output from our program:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to detect data races</title>
      <link>https://yourbasic.org/golang/detect-data-races/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/detect-data-races/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/1443437 --&gt;&#xA;&lt;div style=&#34;float:right;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/sherlock-with-looking-glass.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;Data races can happen easily and are hard to debug. Luckily, the Go runtime is often able to&amp;nbsp;help.&lt;/p&gt;&#xA;&lt;p&gt;Use &lt;code&gt;-race&lt;/code&gt; to enable the built-in data race detector.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$ go test -race [packages]&#xA;$ go run -race [packages]&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s a program with a data race:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;import &#34;fmt&#34;&#xA;&#xA;func main() {&#xA;&#x9;i := 0&#xA;&#x9;go func() {&#xA;&#x9;&#x9;&lt;b&gt;i++&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// write&lt;/span&gt;&#xA;&#x9;}()&#xA;&#x9;&lt;b&gt;fmt.Println(i)&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// concurrent read&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Running this program with the &lt;code&gt;-race&lt;/code&gt; options tells us that there&amp;rsquo;s a race&#xA;between the write at line 7 and the read at line 9:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to disable logging</title>
      <link>https://yourbasic.org/golang/disable-logging-output/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/disable-logging-output/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/log-to-file/&#34;&gt;Write log to file (or /dev/null)&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to find the day of week</title>
      <link>https://yourbasic.org/golang/day-of-week-int/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/day-of-week-int/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/joelanman/366190064 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/calendar-card.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/time/#Time.Weekday&#34;&gt;&lt;code&gt;Weekday&lt;/code&gt;&lt;/a&gt; function&#xA;returns returns the day of the week of a &lt;a href=&#34;https://golang.org/pkg/time/#Time&#34;&gt;&lt;code&gt;time.Time&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func (t Time) Weekday() Weekday&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In use:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;weekday := time.Now().Weekday()&#xA;fmt.Println(weekday)      &lt;span class=&#34;comment&#34;&gt;// &#34;Tuesday&#34;&lt;/span&gt;&#xA;fmt.Println(int(weekday)) &lt;span class=&#34;comment&#34;&gt;// &#34;2&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;type-weekday&#34;&gt;Type Weekday&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/time/#Weekday&#34;&gt;&lt;code&gt;time.Weekday&lt;/code&gt;&lt;/a&gt; type specifies a day of the week (Sunday = 0, …).&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type Weekday int&#xA;&#xA;const (&#xA;&#x9;Sunday Weekday = iota&#xA;&#x9;Monday&#xA;&#x9;Tuesday&#xA;&#x9;Wednesday&#xA;&#x9;Thursday&#xA;&#x9;Friday&#xA;&#x9;Saturday&#xA;)&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>How to get current timestamp</title>
      <link>https://yourbasic.org/golang/current-time/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/current-time/</guid>
      <description>&lt;!-- CC0: https://pixnio.com/es/animales/perros/reloj-de-pulsera-perro-mascota-animal-hombre-camisa-mano --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/wrist-watch-and-dog.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/time/#Now&#34;&gt;&lt;code&gt;time.Now&lt;/code&gt;&lt;/a&gt; and one of&#xA;&lt;a href=&#34;https://golang.org/pkg/time/#Time.Unix&#34;&gt;&lt;code&gt;time.Unix&lt;/code&gt;&lt;/a&gt; or&#xA;&lt;a href=&#34;https://golang.org/pkg/time/#Time.UnixNano&#34;&gt;&lt;code&gt;time.UnixNano&lt;/code&gt;&lt;/a&gt;&#xA;to get a timestamp.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;now := time.Now()      &lt;span class=&#34;comment&#34;&gt;// current local time&lt;/span&gt;&#xA;sec := now.Unix()      &lt;span class=&#34;comment&#34;&gt;// number of seconds since January 1, 1970 UTC&lt;/span&gt;&#xA;nsec := now.UnixNano() &lt;span class=&#34;comment&#34;&gt;// number of nanoseconds since January 1, 1970 UTC&lt;/span&gt;&#xA;&#xA;fmt.Println(now)  &lt;span class=&#34;comment&#34;&gt;// time.Time&lt;/span&gt;&#xA;fmt.Println(sec)  &lt;span class=&#34;comment&#34;&gt;// int64&lt;/span&gt;&#xA;fmt.Println(nsec) &lt;span class=&#34;comment&#34;&gt;// int64&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;2009-11-10 23:00:00 +0000 UTC m=+0.000000000&#xA;1257894000&#xA;1257894000000000000&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>How to kill a goroutine</title>
      <link>https://yourbasic.org/golang/stop-goroutine/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/stop-goroutine/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;One&amp;nbsp;goroutine can&#39;t forcibly stop another.&lt;/p&gt;&#xA;&lt;!-- CC0: https://www.maxpixel.net/Extinguish-Fire-Extinction-Firefighter-484540 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/extinguish-fire.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;To make a goroutine stoppable, let it listen for a stop signal on a dedicated quit channel,&#xA;and check this channel at suitable points in your goroutine.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;quit := make(chan bool)&#xA;go func() {&#xA;&#x9;for {&#xA;&#x9;&#x9;select {&#xA;&#x9;&#x9;case &lt;-quit:&#xA;&#x9;&#x9;&#x9;return&#xA;&#x9;&#x9;default:&#xA;&#x9;&#x9;&#x9;&lt;span class=&#34;comment&#34;&gt;// …&lt;/span&gt;&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;}()&#xA;&lt;span class=&#34;comment&#34;&gt;// …&lt;/span&gt;&#xA;quit &lt;- true&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is a more complete example, where we use a single channel for both data and signalling.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to reverse a string by byte or rune</title>
      <link>https://yourbasic.org/golang/reverse-utf8-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/reverse-utf8-string/</guid>
      <description>&lt;!-- CC BY-SA 4.0: https://commons.wikimedia.org/wiki/File:Ambigram_Ambiguity.png --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/ambiguity-ambigram.png&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;byte-by-byte&#34;&gt;Byte by byte&lt;/h2&gt;&#xA;&lt;p&gt;It&amp;rsquo;s pretty straightforward to reverse a string one byte at a time.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Reverse returns a string with the bytes of s in reverse order.&#xA;func Reverse(s string) string {&#xA;&#x9;var b strings.Builder&#xA;&#x9;b.Grow(len(s))&#xA;&#x9;for i := len(s) - 1; i &gt;= 0; i-- {&#xA;&#x9;&#x9;b.WriteByte(s[i])&#xA;&#x9;}&#xA;&#x9;return b.String()&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;rune-by-rune&#34;&gt;Rune by rune&lt;/h2&gt;&#xA;&lt;p&gt;To reverse a string by UTF-8 encoded characters is a bit trickier.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use JSON with Go [best practices]</title>
      <link>https://yourbasic.org/golang/json-example/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/json-example/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;The JSON data-interchange format is easy for humans to read and write, and efficient for machines to parse and generate.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/en/man-boy-stylish-internet-network-475559/--&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/bits-man.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#default-types&#34;&gt;Default types&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#encode-marshal-struct-to-json&#34;&gt;Encode (marshal) struct to JSON&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pretty-print&#34;&gt;Pretty print&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#decode-unmarshal-json-to-struct&#34;&gt;Decode (unmarshal) JSON to struct&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#arbitrary-objects-and-arrays&#34;&gt;Arbitrary objects and arrays&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#json-file-example&#34;&gt;JSON file example&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;default-types&#34;&gt;Default types&lt;/h2&gt;&#xA;&lt;p&gt;The default Go types for decoding and encoding JSON are&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;bool&lt;/code&gt; for JSON booleans,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;float64&lt;/code&gt; for JSON numbers,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;string&lt;/code&gt; for JSON strings, and&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;nil&lt;/code&gt; for JSON null.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Additionally, &lt;a href=&#34;https://golang.org/pkg/time/#Time&#34;&gt;&lt;code&gt;time.Time&lt;/code&gt;&lt;/a&gt; and&#xA;the numeric types in the  &lt;a href=&#34;https://golang.org/pkg/math/big/&#34;&gt;&lt;code&gt;math/big&lt;/code&gt;&lt;/a&gt; package&#xA;can be automatically encoded as JSON strings.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use the copy function</title>
      <link>https://yourbasic.org/golang/copy-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/copy-explained/</guid>
      <description>&lt;!-- CC BY 4.0: https://commons.wikimedia.org/wiki/File:A_letter-copying_machine;_plan_(top)_and_three-quarter_view_Wellcome_V0023778.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/letter-copying-machine.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The built-in &lt;a href=&#34;https://golang.org/ref/spec#Appending_and_copying_slices&#34;&gt;copy function&lt;/a&gt;&#xA;copies elements into a destination slice &lt;code&gt;dst&lt;/code&gt; from a source slice &lt;code&gt;src&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func copy(dst, src []Type) int&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It returns the number of elements copied,&#xA;which will be the &lt;strong&gt;minimum&lt;/strong&gt; of &lt;code&gt;len(dst)&lt;/code&gt; and &lt;code&gt;len(src)&lt;/code&gt;.&#xA;The result does not depend on whether the arguments overlap.&lt;/p&gt;&#xA;&lt;p&gt;As a &lt;strong&gt;special case&lt;/strong&gt;, it&amp;rsquo;s legal to copy bytes from a string to a slice of bytes.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;copy(dst []byte, src string) int&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;&#xA;&lt;h3 id=&#34;copy-from-one-slice-to-another&#34;&gt;Copy from one slice to another&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;var s = make([]int, 3)&#xA;n := copy(s, []int{0, 1, 2, 3}) &lt;span class=&#34;comment&#34;&gt;// n == 3, s == []int{0, 1, 2}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;copy-from-a-slice-to-itself&#34;&gt;Copy from a slice to itself&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := []int{0, 1, 2}&#xA;n := copy(s, s[1:]) &lt;span class=&#34;comment&#34;&gt;// n == 2, s == []int{1, 2, 2}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;copy-from-a-string-to-a-byte-slice-specialcase&#34;&gt;Copy from a string to a byte slice (special case)&lt;/h3&gt;&#xA;&lt;pre&gt;&lt;code&gt;var b = make([]byte, 5)&#xA;copy(b, &#34;Hello, world!&#34;) &lt;span class=&#34;comment&#34;&gt;// b == []byte(&#34;Hello&#34;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;further-reading&#34;&gt;Further reading&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/orange-thumb.jpg&#34; title=&#34;Slices and arrays in 6 easy steps&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;Slices and arrays in 6 easy steps&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use the io.Reader interface</title>
      <link>https://yourbasic.org/golang/io-reader-interface-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/io-reader-interface-explained/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/still-life-teddy-white-read-book-1037378/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/teddy-bear-reading.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#use-a-built-in-reader&#34;&gt;Use a built-in reader&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#read-directly-from-a-byte-stream&#34;&gt;Read directly from a byte stream&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#buffered-reading-and-scanning&#34;&gt;Buffered reading and scanning&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/io/#Reader&#34;&gt;&lt;code&gt;io.Reader&lt;/code&gt;&lt;/a&gt; &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface&lt;/a&gt; represents an entity&#xA;from which you can read a stream of bytes.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type Reader interface {&#xA;        Read(buf []byte) (n int, err error)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;Read&lt;/code&gt; reads up to &lt;code&gt;len(buf)&lt;/code&gt; bytes into &lt;code&gt;buf&lt;/code&gt; and returns the number of bytes read –&#xA;it returns an &lt;a href=&#34;https://golang.org/pkg/io/#pkg-variables&#34;&gt;&lt;code&gt;io.EOF&lt;/code&gt;&lt;/a&gt; error when the stream ends.&lt;/p&gt;&#xA;&lt;p&gt;The standard library provides numerous Reader&#xA;&lt;a href=&#34;https://golang.org/search?q=Read#Global&#34;&gt;implementations&lt;/a&gt;&#xA;(including in-memory byte buffers, files and network connections),&#xA;and Readers are accepted as input by many utilities&#xA;(including the HTTP client and server implementations).&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to use the io.Writer interface</title>
      <link>https://yourbasic.org/golang/io-writer-interface-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/io-writer-interface-explained/</guid>
      <description>&lt;!-- CC0: http://www.yokota.af.mil/News/Article-Display/Article/773744/yokota-hosts-military-spouse-appreciation-day/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/caligraphy-training.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#how-to-use-a-built-in-writer-3-nbsp-examples&#34;&gt;How to use a built-in writer (3&amp;nbsp;examples)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#optimize-string-writes&#34;&gt;Optimize string writes&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/io/#Writer&#34;&gt;&lt;code&gt;io.Writer&lt;/code&gt;&lt;/a&gt; &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface&lt;/a&gt; represents an entity&#xA;to which you can write a stream of bytes.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type Writer interface {&#xA;        Write(p []byte) (n int, err error)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;Write&lt;/code&gt; writes up to &lt;code&gt;len(p)&lt;/code&gt; bytes from &lt;code&gt;p&lt;/code&gt; to the underlying data stream –&#xA;it returns the number of bytes written and any error encountered that caused&#xA;the write to stop early.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Immutable strings</title>
      <link>https://yourbasic.org/golang/gotcha-strings-are-immutable/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-strings-are-immutable/</guid>
      <description>&lt;!-- CC0: https://www.publicdomainpictures.net/en/view-image.php?image=91579&amp;picture=locked-gate-padlock-chain --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/locked-gate.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t this code compile?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := &#34;hello&#34;&#xA;s[0] = &#39;H&#39;&#xA;fmt.Println(s)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:3:7: cannot assign to s[0]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;Go strings are immutable and behave like read-only byte slices (with a few extra properties).&lt;/p&gt;&#xA;&lt;p&gt;To update the data, use a rune slice instead.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;buf := []rune(&#34;hello&#34;)&#xA;buf[0] = &#39;H&#39;&#xA;s := string(buf)&#xA;fmt.Println(s)  &lt;span class=&#34;comment&#34;&gt;// &#34;Hello&#34;&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;If the string only contains ASCII characters, you could also use a byte&amp;nbsp;slice.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Index out of range</title>
      <link>https://yourbasic.org/golang/gotcha-index-out-of-range/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-index-out-of-range/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/aukirk/9596420966 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/so-close-yet-so-far.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this program crash?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []int{1, 2, 3}&#xA;for i := 1; i &lt;= len(a); i++ {&#xA;&#x9;fmt.Println(a[i])&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;panic: runtime error: index out of range&#xA;&#xA;goroutine 1 [running]:&#xA;main.main()&#xA;&#x9;../main.go:3 +0xe0&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;In the last iteration, &lt;code&gt;i&lt;/code&gt; equals &lt;code&gt;len(a)&lt;/code&gt; which is outside the bounds of&amp;nbsp;&lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Arrays, slices and strings are indexed &lt;strong&gt;starting from zero&lt;/strong&gt; so the values of &lt;code&gt;a&lt;/code&gt; are found at &lt;code&gt;a[0]&lt;/code&gt;, &lt;code&gt;a[1]&lt;/code&gt;, &lt;code&gt;a[2]&lt;/code&gt;, …, &lt;code&gt;a[len(a)-1]&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Insertion sort vs. selection sort (time complexity and performance)</title>
      <link>https://yourbasic.org/algorithms/insertion-sort/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/insertion-sort/</guid>
      <description>&lt;!-- CC0: http://www.publicdomainpictures.net/view-image.php?image=96282&amp;picture=playing-cards --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/sort-playing-cards.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;insertion-sort&#34;&gt;Insertion sort&lt;/h2&gt;&#xA;&lt;p&gt;Insertion sort is a simple sorting algorithm with &lt;strong&gt;quadratic&lt;/strong&gt; worst-case &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-explained/&#34;&gt;time complexity&lt;/a&gt;,&#xA;but in some cases it&amp;rsquo;s still the algorithm of choice.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;It&amp;rsquo;s efficient for &lt;strong&gt;small data sets&lt;/strong&gt;.&#xA;It typically outperforms other simple quadratic algorithms,&#xA;such as selection sort or bubble sort.&lt;/li&gt;&#xA;&lt;li&gt;It&amp;rsquo;s &lt;strong&gt;adaptive&lt;/strong&gt;: it sorts data sets that are already substantially sorted efficiently.&#xA;The time complexity is O(&lt;i&gt;nk&lt;/i&gt;) when each element is at most &lt;i&gt;k&lt;/i&gt; places&#xA;away from its sorted position.&lt;/li&gt;&#xA;&lt;li&gt;It&amp;rsquo;s &lt;strong&gt;stable&lt;/strong&gt;: it doesn&amp;rsquo;t change the order of elements with equal keys.&lt;/li&gt;&#xA;&lt;li&gt;It&amp;rsquo;s &lt;strong&gt;in-place&lt;/strong&gt;: it only requires a constant amount of additional memory.&lt;/li&gt;&#xA;&lt;li&gt;It has &lt;a href=&#34;https://dl.acm.org/citation.cfm?id=1370599&#34;&gt;good branch prediction characteristics&lt;/a&gt;,&#xA;typically limited to a single misprediction per key.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;// InsertionSort sorts the elements of a in ascending order.&#xA;func InsertionSort(a []int) {&#xA;&#x9;for j := 1; j &lt; len(a); j++ {&#xA;&#x9;&#x9;&lt;span class=&#34;comment&#34;&gt;// Invariant: a[:j] contains the same elements as&lt;/span&gt;&#xA;&#x9;&#x9;&lt;span class=&#34;comment&#34;&gt;// the original slice a[:j], but in sorted order.&lt;/span&gt;&#xA;&#x9;&#x9;key := a[j]&#xA;&#x9;&#x9;i := j - 1&#xA;&#x9;&#x9;for i &gt;= 0 &amp;&amp; a[i] &gt; key {&#xA;&#x9;&#x9;&#x9;a[i+1] = a[i]&#xA;&#x9;&#x9;&#x9;i--&#xA;&#x9;&#x9;}&#xA;&#x9;&#x9;a[i+1] = key&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;selection-sort&#34;&gt;Selection sort&lt;/h2&gt;&#xA;&lt;p&gt;In practice, selection sort generally performs worse than insertion sort.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Introduction to graph algorithms: definitions and examples</title>
      <link>https://yourbasic.org/algorithms/graph/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/graph/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:Social_Network_Analysis_Visualization.png --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/social-graph.png&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&#xA;&lt;div style=&#34;float: left; min-width: 35%; margin-right: 2em;&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin:0;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#terminology&#34;&gt;Definitions&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#trees&#34;&gt;Trees&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#directed-graphs&#34;&gt;Directed graphs&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#data-structures&#34;&gt;Data structures&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#adjacency-matrix&#34;&gt;Adjacency matrix&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#adjacency-list&#34;&gt;Adjacency list&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left;&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin:0;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#search-algorithms&#34;&gt;Search algorithms&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#depth-first-search&#34;&gt;Depth-first search (DFS)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#breadth-first-search&#34;&gt;Breadth-first search (BFS)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#dijkstra-s-algorithm&#34;&gt;Dijkstra’s algorithm&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;This text introduces basic graph terminology,&#xA;standard graph data structures, and three fundamental&#xA;algorithms for traversing a graph in a systematic way.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Invalid memory address or nil pointer dereference</title>
      <link>https://yourbasic.org/golang/gotcha-nil-pointer-dereference/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-nil-pointer-dereference/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/vinayshivakumar/3280705941 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/confused.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this program panic?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type Point struct {&#xA;&#x9;X, Y float64&#xA;}&#xA;&#xA;func (p *Point) Abs() float64 {&#xA;&#x9;return math.Sqrt(p.X*p.X + p.Y*p.Y)&#xA;}&#xA;&#xA;func main() {&#xA;&#x9;var p *Point&#xA;&#x9;fmt.Println(p.Abs())&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;panic: runtime error: invalid memory address or nil pointer dereference&#xA;[signal SIGSEGV: segmentation violation code=0xffffffff addr=0x0 pc=0xd2c5a]&#xA;&#xA;goroutine 1 [running]:&#xA;main.(*Point).Abs(...)&#xA;&#x9;../main.go:6&#xA;main.main()&#xA;&#x9;../main.go:11 +0x1a&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The uninitialized pointer &lt;code&gt;p&lt;/code&gt; in the &lt;code&gt;main&lt;/code&gt; function is &lt;code&gt;nil&lt;/code&gt;,&#xA;and you can’t follow the nil pointer.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Is &#34;three&#34; a digit?</title>
      <link>https://yourbasic.org/golang/gotcha-regexp-substring/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-regexp-substring/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/497768 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/texture-three-3-digit.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does the regular expression &lt;code&gt;[0-9]*&lt;/code&gt;, which is supposed to match&#xA;a string with zero or more digits, match a string with characters in it?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;matched, err := regexp.MatchString(`[0-9]*`, &#34;12three45&#34;)&#xA;fmt.Println(matched) // &lt;b&gt;true&lt;/b&gt;&#xA;fmt.Println(err)     // nil (regexp is valid)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The function &lt;a href=&#34;https://golang.org/pkg/regexp/#MatchString&#34;&gt;&lt;code&gt;regexp.MatchString&lt;/code&gt;&lt;/a&gt;&#xA;(as well as most functions in the &lt;a href=&#34;https://golang.org/pkg/regexp/&#34;&gt;&lt;code&gt;regexp&lt;/code&gt;&lt;/a&gt; package)&#xA;does &lt;b&gt;substring&lt;/b&gt; matching.&lt;/p&gt;&#xA;&lt;p&gt;To check if a full string matches &lt;code&gt;[0-9]*&lt;/code&gt;,&#xA;anchor the start and the end of the regular expression:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Iteration variable doesn’t see change in range loop</title>
      <link>https://yourbasic.org/golang/gotcha-range-copy-array/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-range-copy-array/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Astonished-Family-Young-Surprise-Child-Baby-Joy-216876 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/astonished-boy.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t the iteration variable &lt;code&gt;x&lt;/code&gt; notice that &lt;code&gt;a[1]&lt;/code&gt; has been updated?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var a [2]int&#xA;for _, x := range a {&#xA;&#x9;fmt.Println(&#34;x =&#34;, x)&#xA;&#x9;a[1] = 8&#xA;}&#xA;fmt.Println(&#34;a =&#34;, a)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = 0&#xA;x = 0        &lt;span class=&#34;comment&#34;&gt;&amp;lt;- Why isn&#39;t this 8?&lt;/span&gt;&#xA;a = [0 8]&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The range expression &lt;code&gt;a&lt;/code&gt; is evaluated once before beginning the loop&#xA;and a copy of the array is used to generate the iteration values.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Iteration variables and closures</title>
      <link>https://yourbasic.org/golang/gotcha-data-race-closure/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-data-race-closure/</guid>
      <description>&lt;!-- CC BY-NC 2.0: http://www.flickr.com/photos/brandoncwarren/2953838847/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/mid-action.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this program&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;var wg sync.WaitGroup&#xA;&#x9;wg.Add(5)&#xA;&#x9;for i := 0; i &lt; 5; i++ {&#xA;&#x9;&#x9;go func() {&#xA;&#x9;&#x9;&#x9;fmt.Print(i)&#xA;&#x9;&#x9;&#x9;wg.Done()&#xA;&#x9;&#x9;}()&#xA;&#x9;}&#xA;&#x9;wg.Wait()&#xA;&#x9;fmt.Println()&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;print&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;55555&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;(A &lt;a href=&#34;https://yourbasic.org/golang/wait-for-goroutines-waitgroup/&#34;&gt;WaitGroup&lt;/a&gt; waits for a collection of goroutines to finish.)&lt;/p&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;There is a &lt;strong&gt;data race&lt;/strong&gt;: the variable &lt;code&gt;i&lt;/code&gt; is shared&#xA;by six&amp;nbsp;(6) goroutines.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;A data race occurs when two goroutines access the same variable concurrently and at least one of the accesses is a write.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Java to Go in-depth tutorial</title>
      <link>https://yourbasic.org/golang/go-java-tutorial/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/go-java-tutorial/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/yukop/6779040884 --&gt;&#xA;&lt;div class=&#34;extra-content&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/gopher-latte.jpg&#34; width=&#34;200px&#34; style=&#34;float: right; margin: 20px 0 0 20px;&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;This tutorial is in&amp;shy;tended to help Java deve&amp;shy;lopers come up to speed quickly with&amp;nbsp;Go.&lt;/p&gt;&#xA;&lt;div style=&#34;margin-top: 1em&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left; min-width: 30%; margin-right: 2em;&#34;&gt;&#xA;    &lt;ul class=&#34;toc&#34; style=&#34;margin: 0;&#34;&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#hello-stack-example&#34;&gt;Hello stack (example)&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#main-differences&#34;&gt;Main differences&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#syntax&#34;&gt;Syntax&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#constants&#34;&gt;Constants&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#structs&#34;&gt;Structs&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#pointers&#34;&gt;Pointers&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#slices&#34;&gt;Slices&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left;&#34;&gt;&#xA;    &lt;ul class=&#34;toc&#34; style=&#34;margin: 0;&#34;&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#making-values&#34;&gt;Making values&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#methods-and-interfaces&#34;&gt;Methods and interfaces&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#errors&#34;&gt;Errors&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#panic-and-recover&#34;&gt;Panic and recover&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#goroutines-and-channels&#34;&gt;Goroutines and channels&lt;/a&gt;&lt;/li&gt;&#xA;        &lt;li&gt;&lt;a href=&#34;#hello-server-example&#34;&gt;Hello server (example)&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;hello-stack-example&#34;&gt;Hello stack (example)&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start with a small but complete example. It shows how to implement and use a simple abstract data type in Go.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Las Vegas vs. Monte Carlo algorithms</title>
      <link>https://yourbasic.org/algorithms/las-vegas/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/las-vegas/</guid>
      <description>&lt;!-- Public domain: https://en.wikipedia.org/wiki/File:Hubert_Pearce_with_J._B._Rhine.png --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/zener-cards.png&#34;&gt;&lt;/div&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Zener_cards&#34;&gt;Zener cards&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p&gt;A &lt;strong&gt;Las Vegas&lt;/strong&gt; algorithm is a randomized algorithm&#xA;that always gives the correct result but gambles with resources.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Monte Carlo&lt;/strong&gt; simulations are a broad class of algorithms&#xA;that use repeated random sampling to obtain numerical results.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Monte Carlo &lt;b&gt;simulations&lt;/b&gt; are typically used to simulate the behaviour of other systems.&lt;/li&gt;&#xA;&lt;li&gt;Monte Carlo &lt;b&gt;algorithms&lt;/b&gt;, on the other hand,&#xA;are randomized algorithms whose output may be incorrect&#xA;with a certain, typically small, probability.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;random-point-in-circle-lasvegas&#34;&gt;Random point in circle (Las Vegas)&lt;/h2&gt;&#xA;&lt;div&gt;&lt;img style=&#34;float:right; margin-left:1em;&#34; src=&#34;https://yourbasic.org/algorithms/circle.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;It&amp;rsquo;s easy and convenient to compute a random point in a circle with a Las Vegas algorithm.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Last item in a slice/array</title>
      <link>https://yourbasic.org/golang/last-item-in-slice/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/last-item-in-slice/</guid>
      <description>&lt;!-- CC0: https://www.airforcemedicine.af.mil/News/Photos/igphoto/2001962857/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/surgical-removal.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;read-last-element&#34;&gt;Read last element&lt;/h2&gt;&#xA;&lt;p&gt;Use the index &lt;code&gt;len(a)-1&lt;/code&gt; to access the last element of&#xA;a slice or array &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []string{&#34;A&#34;, &#34;B&#34;, &#34;C&#34;}&#xA;s := a[len(a)-1] &lt;span class=&#34;comment&#34;&gt;// C&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;Go doesn&#39;t have negative indexing like Python does.&#xA;This is a deliberate design decision —&#xA;keeping the language simple can help save you from&#xA;&lt;a href=&#34;https://github.com/golang/go/issues/11245&#34;&gt;subtle bugs&lt;/a&gt;.&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;remove-last-element&#34;&gt;Remove last element&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;a = a[:len(a)-1] &lt;span class=&#34;comment&#34;&gt;// [A B]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;watch-out-for-memory-leaks&#34;&gt;Watch out for memory leaks&lt;/h3&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; If the slice is permanent and the element temporary,&#xA;you may want to remove the reference to the element before slicing it off.&#xA;&lt;pre&gt;&lt;code&gt;a[len(a)-1] = &#34;&#34; &lt;span class=&#34;comment&#34;&gt;// Erase element (write zero value)&lt;/span&gt;&#xA;a = a[:len(a)-1] &lt;span class=&#34;comment&#34;&gt;// [A B]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;further-reading&#34;&gt;Further reading&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/orange-thumb.jpg&#34; title=&#34;Slices and arrays in 6 easy steps&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;Slices and arrays in 6 easy steps&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Learn to love your compiler</title>
      <link>https://yourbasic.org/golang/compiler-error-messages/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/compiler-error-messages/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;The Go compiler sometimes confuses and annoys developers who are new to the&amp;nbsp;language.&lt;/p&gt;&#xA;&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/maf04/12526435063 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/tree-of-love.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;This is a list of short articles with strategies and workarounds&#xA;for common compiler error messages that tend to confuse fresh Go programmers.&lt;/p&gt;&#xA;&lt;ul class=&#34;none&#34;&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/unused-imports/&#34;&gt;&lt;code&gt;imported and not used&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;Programs with unused imports won&#39;t compile.&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/unused-local-variables/&#34;&gt;&lt;code&gt;declared and not used&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;You must use all local variables.&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/gotcha-multiple-value-single-value-context/&#34;&gt;&lt;code&gt;multiple-value in single-value context&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;When a function returns multiple values, you must use all of them.&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/gotcha-missing-comma-slice-array-map-literal/&#34;&gt;&lt;code&gt;syntax error: unexpected newline, expecting comma or }&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;In a multi-line slice, array or map literal, every line must end with a comma.&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/gotcha-strings-are-immutable/&#34;&gt;&lt;code&gt;cannot assign to …&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;Go strings are immutable and behave like read-only byte slices.&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/gotcha-constant-overflows-int/&#34;&gt;&lt;code&gt;constant overflows int&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;An untyped constant is converted before it is assigned to a variable.&lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/gotcha-increment-decrement-statement/&#34;&gt;&lt;code&gt;syntax error: unexpected ++, expecting expression comma or )&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;Increment and decrement operations can’t be used as expressions, only as statements. &lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/short-variable-declaration-outside-function/&#34;&gt;&lt;code&gt;syntax error: non-declaration statement outside function body&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;Short variable declarations can only be used inside functions. &lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;  &lt;a href=&#34;https://yourbasic.org/golang/opening-brace-separate-line/&#34;&gt;&lt;code&gt;missing function body for …&lt;/code&gt;&lt;/a&gt;&#xA;  &lt;div style=&#34;padding: 0.5em 0 1em 0&#34;&gt;An opening brace cannot appear on a line by itself. &lt;/div&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>List all files (recursively) in a directory</title>
      <link>https://yourbasic.org/golang/list-files-in-directory/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/list-files-in-directory/</guid>
      <description>&lt;h2 id=&#34;directory-listing&#34;&gt;Directory listing&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/io/ioutil/#ReadDir&#34;&gt;&lt;code&gt;ioutil.ReadDir&lt;/code&gt;&lt;/a&gt; function in package &lt;a href=&#34;https://golang.org/pkg/io/ioutil/&#34;&gt;&lt;code&gt;io/ioutil&lt;/code&gt;&lt;/a&gt;. It returns a sorted slice containing elements of type &lt;a href=&#34;https://golang.org/pkg/os/#FileInfo&#34;&gt;&lt;code&gt;os.FileInfo&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The code in this example prints a sorted list of all file names in the current directory.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;files, err := ioutil.ReadDir(&#34;.&#34;)&#xA;if err != nil {&#xA;&#x9;log.Fatal(err)&#xA;}&#xA;for _, f := range files {&#xA;&#x9;fmt.Println(f.Name())&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Example output:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;dev&#xA;etc&#xA;tmp&#xA;usr&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;visit-all-files-and-folders-in-a-directory-tree&#34;&gt;Visit all files and folders in a directory tree&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;a href=&#34;https://golang.org/pkg/path/filepath/#Walk&#34;&gt;&lt;code&gt;filepath.Walk&lt;/code&gt;&lt;/a&gt; function in package &lt;a href=&#34;https://golang.org/pkg/path/filepath/&#34;&gt;&lt;code&gt;path/filepath&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Loop invariants can give you coding superpowers</title>
      <link>https://yourbasic.org/algorithms/loop-invariants-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/loop-invariants-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;An invariant is a state&amp;shy;ment about program vari&amp;shy;ables that&#xA;is true every time the execu&amp;shy;tion of the program reaches the&amp;nbsp;invariant.&lt;/p&gt;&#xA;&lt;!-- CC BY 2.0: https://www.flickr.com/photos/hulagway/5315234736 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/vanishing-point.jpg&#34; alt=&#34;Repeating circular patterns&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#loop-invariant-definition&#34;&gt;Loop invariant definition (basic example)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#designing-with-invariants&#34;&gt;Designing with invariants&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#sorting&#34;&gt;Sorting (trickier example)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#3-way-partition&#34;&gt;3-way partition (advanced example)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;When struggling with a tricky 3-way partition algorithm as a student,&#xA;a friend suggested a well-fitting invariant.&#xA;It was like getting a secret superpower: suddenly I could write code&#xA;that used to be impossible.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Make slices, maps and channels</title>
      <link>https://yourbasic.org/golang/make-slice-map-channel/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/make-slice-map-channel/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/golang/slices-explained/&#34;&gt;Slices&lt;/a&gt;, &lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;maps&lt;/a&gt;&#xA;and &lt;a href=&#34;https://yourbasic.org/golang/channels-explained/&#34;&gt;channels&lt;/a&gt; can be created with the built-in &lt;code&gt;make&lt;/code&gt; function.&#xA;The memory is initialized with &lt;a href=&#34;https://yourbasic.org/golang/default-zero-value/&#34;&gt;zero values&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Call&lt;/th&gt;&#xA;      &lt;th&gt;Type&lt;/th&gt;&#xA;      &lt;th&gt;Description&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;make(T, n)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;slice&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;slice of type T with length&amp;nbsp;n&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;make(T, n, c)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt; &lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;capacity c&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;make(T)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;map&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;map of type&amp;nbsp;T&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;make(T, n)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt; &lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;initial room for approximately n&amp;nbsp;elements&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;make(T)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;channel&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;unbuffered channel of type&amp;nbsp;T&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;make(T, n)&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt; &lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;buffered channel with buffer size&amp;nbsp;n&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := make([]int, 10, 100)      &lt;span class=&#34;comment&#34;&gt;// slice with len(s) == 10, cap(s) == 100&lt;/span&gt;&#xA;m := make(map[string]int, 100) &lt;span class=&#34;comment&#34;&gt;// map with initial room for ~100 elements&lt;/span&gt;&#xA;c := make(chan int, 10)        &lt;span class=&#34;comment&#34;&gt;// channel with a buffer size of 10&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Slices, arrays and maps can also be created with&#xA;&lt;a href=&#34;https://golang.org/ref/spec#Composite_literals&#34;&gt;composite literals&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Maps explained: create, add, get, delete</title>
      <link>https://yourbasic.org/golang/maps-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/maps-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Go maps are implemented by hash tables and have efficient add, get and delete operations.&lt;/p&gt;&#xA;&lt;!-- CC0: https://en.wikipedia.org/wiki/File:Great_presidential_puzzle2.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/15-men-16-slots.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#create-a-new-map&#34;&gt;Create a new map&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#add-update-get-and-delete-keys-values&#34;&gt;Add, update, get and delete keys/values&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#for-each-range-loop&#34;&gt;For-each range loop&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance-and-implementation&#34;&gt;Performance and implementation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;create-a-new-map&#34;&gt;Create a new map&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;var m map[string]int                &lt;span class=&#34;comment&#34;&gt;// nil map of string-int pairs&lt;/span&gt;&#xA;&#xA;m1 := make(map[string]float64)      &lt;span class=&#34;comment&#34;&gt;// Empty map of string-float64 pairs&lt;/span&gt;&#xA;m2 := make(map[string]float64, 100) &lt;span class=&#34;comment&#34;&gt;// Preallocate room for 100 entries&lt;/span&gt;&#xA;&#xA;m3 := map[string]float64{           &lt;span class=&#34;comment&#34;&gt;// Map literal&lt;/span&gt;&#xA;    &#34;e&#34;:  2.71828,&#xA;    &#34;pi&#34;: 3.1416,&#xA;}&#xA;fmt.Println(len(m3))                &lt;span class=&#34;comment&#34;&gt;// Size of map: 2&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A map (or dictionary) is an &lt;b&gt;unordered&lt;/b&gt; collection of &lt;b&gt;key-value&lt;/b&gt; pairs, where each key is &lt;b&gt;unique&lt;/b&gt;.&lt;/li&gt;&#xA;&lt;li&gt;You create a new map  with a &lt;strong&gt;&lt;a href=&#34;https://golang.org/pkg/builtin/#make&#34;&gt;make&lt;/a&gt;&lt;/strong&gt; statement or a &lt;strong&gt;map literal&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The default &lt;strong&gt;zero value&lt;/strong&gt; of a map is &lt;code&gt;nil&lt;/code&gt;.&#xA;A nil map is equivalent to an empty map except&#xA;that &lt;strong&gt;elements can&amp;rsquo;t be added&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;b&gt;&lt;a href=&#34;https://golang.org/pkg/builtin/#len&#34;&gt;&lt;code&gt;len&lt;/code&gt;&lt;/a&gt;&lt;/b&gt; function&#xA;returns the &lt;strong&gt;size&lt;/strong&gt; of a map, which is the number of key-value pairs.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; If you try to add an element to an uninitialized map you get the mysterious run-time error&#xA;&lt;a href=&#34;https://yourbasic.org/golang/gotcha-assignment-entry-nil-map/&#34;&gt;&lt;em&gt;Assignment to entry in nil map&lt;/em&gt;&lt;/a&gt;.&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;add-update-get-and-delete-keysvalues&#34;&gt;Add, update, get and delete keys/values&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := make(map[string]float64)&#xA;&#xA;m[&#34;pi&#34;] = 3.14             &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Add a new key-value pair&lt;/b&gt;&lt;/span&gt;&#xA;m[&#34;pi&#34;] = 3.1416           &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Update value&lt;/b&gt;&lt;/span&gt;&#xA;fmt.Println(m)             &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Print map:&lt;/b&gt; &#34;map[pi:3.1416]&#34;&lt;/span&gt;&#xA;&#xA;v := m[&#34;pi&#34;]               &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Get value:&lt;/b&gt; v == 3.1416&lt;/span&gt;&#xA;v = m[&#34;pie&#34;]               &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Not found:&lt;/b&gt; v == 0 (zero value)&lt;/span&gt;&#xA;&#xA;_, found := m[&#34;pi&#34;]        &lt;span class=&#34;comment&#34;&gt;// found == true&lt;/span&gt;&#xA;_, found = m[&#34;pie&#34;]        &lt;span class=&#34;comment&#34;&gt;// found == false&lt;/span&gt;&#xA;&#xA;if x, found := m[&#34;pi&#34;]; found {&#xA;&#x9;fmt.Println(x)&#xA;}                           &lt;span class=&#34;comment&#34;&gt;// Prints &#34;3.1416&#34;&lt;/span&gt;&#xA;&#xA;delete(m, &#34;pi&#34;)             &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Delete a key-value pair&lt;/b&gt;&lt;/span&gt;&#xA;fmt.Println(m)              &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;Print map:&lt;/b&gt; &#34;map[]&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When you index a map you get two return values;&#xA;the second one (which is optional) is a boolean that indicates if the key exists.&lt;/li&gt;&#xA;&lt;li&gt;If the key doesn&amp;rsquo;t exist, the first value will be the default&#xA;&lt;a href=&#34;https://yourbasic.org/golang/default-zero-value/&#34;&gt;zero value&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;for-each-range-loop&#34;&gt;For-each range loop&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := map[string]float64{&#xA;&#x9;&#34;pi&#34;: 3.1416,&#xA;&#x9;&#34;e&#34;:  2.71828,&#xA;}&#xA;fmt.Println(m) &lt;span class=&#34;comment&#34;&gt;// &#34;map[e:2.71828 pi:3.1416]&#34;&lt;/span&gt;&#xA;&#xA;for key, value := range m { &lt;span class=&#34;comment&#34;&gt;// Order not specified&lt;/span&gt; &#xA;&#x9;fmt.Println(key, value)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Iteration order is not specified and may vary from iteration to iteration.&lt;/li&gt;&#xA;&lt;li&gt;If an entry that has not yet been reached is removed during iteration,&#xA;the corresponding iteration value will not be produced.&lt;/li&gt;&#xA;&lt;li&gt;If an entry is created during iteration,&#xA;that entry may or may not be produced during the iteration.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Starting with &lt;a href=&#34;https://tip.golang.org/doc/go1.12&#34;&gt;Go 1.12&lt;/a&gt;,&#xA;the &lt;a href=&#34;https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/&#34;&gt;fmt package&lt;/a&gt;&#xA;prints maps in key-sorted order to ease testing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Maximum value of an int</title>
      <link>https://yourbasic.org/golang/max-min-int-uint/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/max-min-int-uint/</guid>
      <description>&lt;p&gt;Go has two predeclared integer types with implementation-specific sizes:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;code&gt;uint&lt;/code&gt; (unsigned integer) has either 32 or 64 bits,&lt;/li&gt;&#xA;&lt;li&gt;an &lt;code&gt;int&lt;/code&gt; (signed integer) has the same size as a &lt;code&gt;uint&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This code computes the limit values as &lt;strong&gt;untyped constants&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const UintSize = 32 &lt;&lt; (^uint(0) &gt;&gt; 32 &amp; 1) &lt;span class=&#34;comment&#34;&gt;// 32 or 64&lt;/span&gt;&#xA;&#xA;const (&#xA;&#x9;MaxInt  = 1&amp;lt;&amp;lt;(UintSize-1) - 1 &lt;span class=&#34;comment&#34;&gt;// 1&lt;&lt;31 - 1 or 1&lt;&lt;63 - 1&lt;/span&gt;&#xA;&#x9;MinInt  = -MaxInt - 1         &lt;span class=&#34;comment&#34;&gt;// -1 &lt;&lt; 31 or -1 &lt;&lt; 63&lt;/span&gt;&#xA;&#x9;MaxUint = 1&amp;lt;&amp;lt;UintSize - 1     &lt;span class=&#34;comment&#34;&gt;// 1&lt;&lt;32 - 1 or 1&lt;&lt;64 - 1&lt;/span&gt;&#xA;)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/math/bits/#pkg-constants&#34;&gt;&lt;code&gt;UintSize&lt;/code&gt;&lt;/a&gt; constant&#xA;is also available in package &lt;a href=&#34;https://golang.org/pkg/math/bits/&#34;&gt;&lt;code&gt;math/bits&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Measure execution time</title>
      <link>https://yourbasic.org/golang/measure-execution-time/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/measure-execution-time/</guid>
      <description>&lt;!-- CC BY-SA 4.0: https://commons.wikimedia.org/wiki/File:Leichtathletik_Gala_Linz_2017_100m_M%C3%A4nner-6726.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/100m-sprint.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;measure-a-piece-of-code&#34;&gt;Measure a piece of code&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;b&gt;start := time.Now()&lt;/b&gt;&#xA;&lt;span style=&#34;color: green&#34;&gt;// Code to measure&lt;/span&gt;&#xA;&lt;b&gt;duration := time.Since(start)&lt;/b&gt;&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Formatted string, such as &#34;2h3m0.5s&#34; or &#34;4.503μs&#34;&lt;/span&gt;&#xA;fmt.Println(duration)&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Nanoseconds as int64&lt;/span&gt;&#xA;fmt.Println(duration.Nanoseconds())&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;measure-a-function-call&#34;&gt;Measure a function call&lt;/h2&gt;&#xA;&lt;p&gt;You can track the execution time of a complete function call with this one-liner,&#xA;which logs the result to the standard error stream.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func foo() {&#xA;&#x9;&lt;b&gt;defer duration(track(&#34;foo&#34;))&lt;/b&gt;&#xA;&#x9;&lt;span style=&#34;color: green&#34;&gt;// Code to measure&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;func track(msg string) (string, time.Time) {&#xA;&#x9;return msg, time.Now()&#xA;}&#xA;&#xA;func duration(msg string, start time.Time) {&#xA;&#x9;log.Printf(&#34;%v: %v\n&#34;, msg, time.Since(start))&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;benchmarks&#34;&gt;Benchmarks&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/testing/&#34;&gt;&lt;code&gt;testing&lt;/code&gt;&lt;/a&gt; package has support for&#xA;benchmarking that can be used to examine the performance of your code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Methods explained</title>
      <link>https://yourbasic.org/golang/methods-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/methods-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Go doesn&#39;t have classes, but you can define methods on types.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pxhere.com/en/photo/1452109 --&gt;&#xA;&lt;div &gt;&lt;img src=&#34;https://yourbasic.org/golang/house-with-methods.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;You can define methods on any type declared in a type definition.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;A method is a function with an extra &lt;strong&gt;receiver&lt;/strong&gt; argument.&lt;/li&gt;&#xA;&lt;li&gt;The receiver sits between the &lt;code&gt;func&lt;/code&gt; keyword and the method name.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In this example, the &lt;code&gt;HasGarage&lt;/code&gt; method is associated with the &lt;code&gt;House&lt;/code&gt; type.&#xA;The method receiver is called &lt;code&gt;p&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;skiphl&#34;&gt;type House struct {&#xA;&#x9;garage bool&#xA;}&#xA;&#xA;func &lt;b&gt;(p *House)&lt;/b&gt; HasGarage() bool { return p.garage }&#xA;&#xA;func main() {&#xA;&#x9;house := new(House)&#xA;&#x9;fmt.Println(house.HasGarage()) &lt;span class=&#34;comment&#34;&gt;// Prints &#34;false&#34; (zero value)&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;conversions-and-methods&#34;&gt;Conversions and methods&lt;/h3&gt;&#xA;&lt;p&gt;If you &lt;a href=&#34;https://yourbasic.org/golang/conversions/&#34;&gt;convert&lt;/a&gt; a value to a different type,&#xA;the new value will have the methods of the new type, but not the old.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Missing function body</title>
      <link>https://yourbasic.org/golang/opening-brace-separate-line/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/opening-brace-separate-line/</guid>
      <description>&lt;!-- CC0: https://picryl.com/media/pencil-macro-red-177beb --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/red-pencil.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;As you may have noticed, programs with an opening brace on separate line do not compile.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func main()&#xA;{&#xA;&#x9;fmt.Println(&amp;#34;Hello&amp;#34;)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:1:6: missing function body for &amp;#34;main&amp;#34;&#xA;../main.go:2:1: syntax error: unexpected semicolon or newline before {&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You must write:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func main() {&#xA;&#x9;fmt.Println(&amp;#34;Hello&amp;#34;)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is a trade-off in the design of the Go language.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Some have argued that the lexer should do lookahead to permit the brace to live on the next line.&#xA;We disagree. Since Go code is meant to be formatted automatically by &lt;strong&gt;gofmt&lt;/strong&gt;,&#xA;some style must be chosen. [&amp;hellip;] The advantages of a single, programmatically mandated format&#xA;for all Go programs greatly outweigh any perceived disadvantages of the particular style.&#xA;&lt;a class=&#34;quote-source&#34; href=&#34;https://golang.org/doc/faq#semicolons&#34;&gt;Go FAQ: Why are there braces but no semicolons? And why can&amp;rsquo;t I put the opening brace on the next line?&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Multiple-value in single-value context</title>
      <link>https://yourbasic.org/golang/gotcha-multiple-value-single-value-context/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-multiple-value-single-value-context/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Number-Series-2-123-Digits-Pay-One-Two-1-3-705666 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/single-vs-multiple-values.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this code give a compile error?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;t := time.Parse(time.RFC3339, &#34;2018-04-06T10:49:05Z&#34;)&#xA;fmt.Println(t)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:9:17: multiple-value time.Parse() in single-value context&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/time/#Parse&#34;&gt;&lt;code&gt;time.Parse&lt;/code&gt;&lt;/a&gt; function returns two values,&#xA;a &lt;a href=&#34;https://golang.org/pkg/time/#Time&#34;&gt;&lt;code&gt;time.Time&lt;/code&gt;&lt;/a&gt; and&#xA;an &lt;a href=&#34;https://yourbasic.org/golang/errors-explained/&#34;&gt;&lt;code&gt;error&lt;/code&gt;&lt;/a&gt;, and you must use&amp;nbsp;both.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;t, err := time.Parse(time.RFC3339, &#34;2018-04-06T10:49:05Z&#34;)&#xA;if err != nil {&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// TODO: Handle error.&lt;/span&gt;&#xA;}&#xA;fmt.Println(t)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;2018-04-06 10:49:05 +0000 UTC&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;blank-identifier-underscore&#34;&gt;Blank identifier (underscore)&lt;/h3&gt;&#xA;&lt;p&gt;You can use the &lt;a href=&#34;https://yourbasic.org/golang/underscore/&#34;&gt;blank identifier&lt;/a&gt;&#xA;to ignore unwanted return values.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;m := map[string]float64{&#34;pi&#34;: 3.1416}&#xA;_, exists := m[&#34;pi&#34;] &lt;span class=&#34;comment&#34;&gt;// exists == true&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Mutual exclusion lock (mutex)</title>
      <link>https://yourbasic.org/golang/mutex-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/mutex-explained/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Mutexes let you synchronize data access by explicit locking, without channels.&lt;/p&gt;&#xA;&lt;!-- CC BY-NC-ND 2.0: http://www.flickr.com/photos/dzarro72/7187334179/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/lock.jpg&#34; alt=&#34;lock&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Sometimes it’s more convenient to synchronize data access by explicit locking instead of using channels. The Go standard library offers a mutual exclusion lock, &lt;a href=&#34;https://golang.org/pkg/sync/#Mutex&#34;&gt;sync.Mutex&lt;/a&gt;, for this purpose.&lt;/p&gt;&#xA;&lt;h2 id=&#34;use-with-caution&#34;&gt;Use with caution&lt;/h2&gt;&#xA;&lt;p&gt;For this type of locking to be safe, it&amp;rsquo;s crucial that all accesses&#xA;to the shared data, both reads and writes, are performed only&#xA;when a goroutine holds the lock. One mistake by a single goroutine&#xA;is enough to introduce a data race and break the program.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Named return values [best practice]</title>
      <link>https://yourbasic.org/golang/named-return-values-parameters/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/named-return-values-parameters/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/robertnyman/4030997193 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/geek-tattoo.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;In Go return parameters may be named and used as regular variables. When the function returns,&#xA;they are used as return values.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;skiphl&#34;&gt;func f() &lt;b&gt;(i int, s string)&lt;/b&gt; {&#xA;&#x9;i = 17&#xA;&#x9;s = &#34;abc&#34;&#xA;&#x9;&lt;b&gt;return&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// same as return i, s&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Named return parameters are initialized to their &lt;a href=&#34;https://yourbasic.org/golang/default-zero-value/&#34;&gt;zero values&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The names are not mandatory but can make for good documentation. Correctly used, named return parameters can also help clarify and clean up the code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Nil is not nil</title>
      <link>https://yourbasic.org/golang/gotcha-why-nil-error-not-equal-nil/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-why-nil-error-not-equal-nil/</guid>
      <description>&lt;!--CC BY 2.0: https://www.flickr.com/photos/davidpacey1975/9049992204 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/odd-one-out.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why is nil not equal to nil in this example?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Foo() error {&#xA;&#x9;var err *os.PathError = nil&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// …&lt;/span&gt;&#xA;&#x9;return err&#xA;}&#xA;&#xA;func main() {&#xA;&#x9;err := Foo()&#xA;&#x9;fmt.Println(err)        &lt;span class=&#34;comment&#34;&gt;// &amp;lt;nil&amp;gt;&lt;/span&gt;&#xA;&#x9;fmt.Println(&lt;b&gt;err == nil&lt;/b&gt;) &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;An interface value is equal to &lt;code&gt;nil&lt;/code&gt; only if both its value and dynamic type are &lt;code&gt;nil&lt;/code&gt;.&#xA;In the example above, &lt;code&gt;Foo()&lt;/code&gt; returns &lt;code&gt;[nil, *os.PathError]&lt;/code&gt; and we compare it with &lt;code&gt;[nil,&amp;nbsp;nil]&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>No end in sight</title>
      <link>https://yourbasic.org/golang/gotcha-integer-overflow-wrap-around/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-integer-overflow-wrap-around/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/nanpalmero/4348149625 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/1-infinite-loop.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this loop run forever?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var b byte&#xA;for b = 250; b &lt;= 255; b++ {&#xA;&#x9;fmt.Printf(&#34;%d %c\n&#34;, b, b)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;After the &lt;code&gt;b == 255&lt;/code&gt; iteration, &lt;code&gt;b++&lt;/code&gt; is executed. This overflows (since the maximum value for a byte is 255) and results in &lt;code&gt;b == 0&lt;/code&gt;. Therefore &lt;code&gt;b &amp;lt;= 255&lt;/code&gt; still holds and the loop restarts from&amp;nbsp;0.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&#xA;For unsigned integer values, the operations +, -, *, and &amp;lt;&amp;lt; are computed modulo 2&lt;sup&gt;n&lt;/sup&gt;,&#xA;where n is the bit width of the unsigned integer type.&#xA;&lt;/p&gt;</description>
    </item>
    <item>
      <title>No JSON in sight</title>
      <link>https://yourbasic.org/golang/gotcha-json-marshal-empty/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-json-marshal-empty/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/940438 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/empty-book.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does &lt;a href=&#34;https://golang.org/pkg/encoding/json/#Marshal&#34;&gt;&lt;code&gt;json.Marshal&lt;/code&gt;&lt;/a&gt;&#xA;produce empty structs in the JSON text output?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type Person struct {&#xA;&#x9;name string&#xA;&#x9;age  int&#xA;}&#xA;&#xA;p := Person{&#34;Alice&#34;, 22}&#xA;jsonData, _ := json.Marshal(p)&#xA;fmt.Println(string(jsonData))&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;Only &lt;strong&gt;exported&lt;/strong&gt; fields of a Go struct will be present in the JSON output.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;skiphl&#34;&gt;type Person struct {&#xA;&#x9;&lt;b&gt;Name&lt;/b&gt; string &lt;span class=&#34;comment&#34;&gt;// Changed to capital N&lt;/span&gt;&#xA;&#x9;&lt;b&gt;Age&lt;/b&gt;  int    &lt;span class=&#34;comment&#34;&gt;// Changed to capital A&lt;/span&gt;&#xA;}&#xA;&#xA;p := Person{&#34;Alice&#34;, 22}&#xA;&#xA;jsonData, _ := json.Marshal(p)&#xA;fmt.Println(string(jsonData))&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code&gt;{&#34;Name&#34;:&#34;Alice&#34;,&#34;Age&#34;:22}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can specify the JSON field name explicitly with a &lt;code&gt;json:&lt;/code&gt;&amp;nbsp;tag.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Non-declaration statement outside function body</title>
      <link>https://yourbasic.org/golang/short-variable-declaration-outside-function/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/short-variable-declaration-outside-function/</guid>
      <description>&lt;!-- CC BY-NC-ND 2.0: https://www.flickr.com/photos/ruminatrix/3052493260/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/syntax-terror-640.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;As you may have noticed, a program with short variable declarations&#xA;outside a function doesn&amp;rsquo;t compile.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&#xA;n := 1 &lt;span class=&#34;comment&#34;&gt;// illegal&lt;/span&gt;&#xA;&#xA;func main() {}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:3:1: syntax error: non-declaration statement outside function body&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Short variable declarations can only be used inside functions.&#xA;You have to write&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&#xA;&lt;b&gt;var n = 1&lt;/b&gt;&#xA;&#xA;func main() {}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is a trade-off in the design of the Go language.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Numbers that start with zero</title>
      <link>https://yourbasic.org/golang/gotcha-octal-decimal-hexadecimal-literal/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-octal-decimal-hexadecimal-literal/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/glynlowe/22573628975 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/007.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;What&amp;rsquo;s up with the counting in this example?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const (&#xA;&#x9;Century = 100&#xA;&#x9;Decade  = 010&#xA;&#x9;Year    = 001&#xA;)&#xA;&lt;span class=&#34;comment&#34;&gt;// The world&#39;s oldest person, Emma Morano, lived for a century,&lt;/span&gt;&#xA;&lt;span class=&#34;comment&#34;&gt;// two decades and two years.&lt;/span&gt;&#xA;fmt.Println(&#34;She was&#34;, Century+2*Decade+2*Year, &#34;years old.&#34;)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;She was 118 years old.&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;&lt;code&gt;010&lt;/code&gt; is a number in &lt;b&gt;base&amp;nbsp;8&lt;/b&gt;, therefore it means&amp;nbsp;8, not&amp;nbsp;10.&lt;/p&gt;&#xA;&lt;p&gt;Integer literals in Go are specified in octal, decimal or hexadecimal.&#xA;The number 16 can be written as &lt;code&gt;020&lt;/code&gt;, &lt;code&gt;16&lt;/code&gt; or &lt;code&gt;0x10&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>O(n log log n) time integer sorting</title>
      <link>https://yourbasic.org/algorithms/fastest-sorting-algorithm/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/fastest-sorting-algorithm/</guid>
      <description>&lt;!-- CC BY-NC 2.0: http://www.flickr.com/photos/davidsingleton/2175975083/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/sorted.jpg&#34; alt=&#34;Programmer in a sea of balls&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-fastest-sorting-algorithm&#34;&gt;The fastest sorting algorithm?&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-problem&#34;&gt;The problem&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-algorithm&#34;&gt;The algorithm&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#reducing-number-size&#34;&gt;Reducing number size&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#fast-merging-of-short-numbers&#34;&gt;Fast merging of short numbers&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;the-fastest-sorting-algorithm&#34;&gt;The fastest sorting algorithm?&lt;/h2&gt;&#xA;&lt;p&gt;&#xA;Which sorting algorithm is the fastest?&#xA;Ask this question to any group of programmers and you’ll get an animated discussion.&#xA;Of course, there is no one answer.&#xA;It depends not only on the algorithm, but also on the computer, data, and implementation.&#xA;However, if you count the number of operations needed to sort integer numbers&#xA;on a standard von Neumann computer, there is a clear winner –&#xA;the algorithm presented in the paper&#xA;“Sorting In Linear Time?” by A.&amp;nbsp;Andersson, T.&amp;nbsp;Hagerup, S.&amp;nbsp;Nilsson, and R.&amp;nbsp;Raman&#xA;(&lt;i&gt;Proceedings of the 27th Annual ACM Symposium on the Theory of Computing&lt;/i&gt;, 1995).&#xA;It sorts &lt;i&gt;n&lt;/i&gt; integers in time proportional to &lt;i&gt;n&lt;/i&gt;&amp;nbsp;log&amp;nbsp;log&amp;nbsp;&lt;i&gt;n&lt;/i&gt;.&#xA;In this article, I’ll give you a complete description of this algorithm.&#xA;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Object-oriented programming without inheritance</title>
      <link>https://yourbasic.org/golang/inheritance-object-oriented/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/inheritance-object-oriented/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Go doesn’t have inheritance &amp;ndash;&#xA;instead composition, embed&amp;shy;ding and inter&amp;shy;faces support code reuse and poly&amp;shy;morphism.&lt;/p&gt;&#xA;&lt;!-- CC BY-SA 4.0: https://commons.wikimedia.org/wiki/File:Performance-Evaluation-Process-z.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/improvement.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#object-oriented-programming-with-inheritance&#34;&gt;Object-oriented programming with inheritance&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#code-reuse-by-composition&#34;&gt;Code reuse by composition&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#code-reuse-by-embedding&#34;&gt;Code reuse by embedding&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#polymorphism-and-dynamic-dispatch-with-interfaces&#34;&gt;Polymorphism and dynamic dispatch with interfaces&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;object-oriented-programming-with-inheritance&#34;&gt;Object-oriented programming with inheritance&lt;/h2&gt;&#xA;&lt;p&gt;Inheritance in traditional object-oriented languages offers three features in one.&#xA;When a &lt;code&gt;Dog&lt;/code&gt; inherits from an &lt;code&gt;Animal&lt;/code&gt;&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;the &lt;code&gt;Dog&lt;/code&gt; class reuses code from the &lt;code&gt;Animal&lt;/code&gt; class,&lt;/li&gt;&#xA;&lt;li&gt;a variable &lt;code&gt;x&lt;/code&gt;  of type &lt;code&gt;Animal&lt;/code&gt; can refer to either a &lt;code&gt;Dog&lt;/code&gt; or an &lt;code&gt;Animal&lt;/code&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;x.Eat()&lt;/code&gt; will choose an &lt;code&gt;Eat&lt;/code&gt; method based on what type of object &lt;code&gt;x&lt;/code&gt; refers to.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;In object-oriented lingo, these features are known as &lt;b&gt;code reuse&lt;/b&gt;, &lt;b&gt;poly­mor­phism&lt;/b&gt; and &lt;b&gt;dynamic dispatch&lt;/b&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>On induction and recursive functions, with an application to binary search</title>
      <link>https://yourbasic.org/algorithms/induction-recursive-functions/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/induction-recursive-functions/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;To make sense of recursive functions, you can use a way of thinking closely related to mathematical induction.&lt;/p&gt;&#xA;&lt;!-- CC BY-NC-SA 2.0: https://www.flickr.com/photos/gadl/254387060/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/recursive-flower.jpg&#34; alt=&#34;Repeating circular patterns&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#mathematical-induction&#34;&gt;Mathematical induction&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#sum-of-an-arithmetic-series&#34;&gt;Sum of an arithmetic series (basic example)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-same-sum-in-code&#34;&gt;The same sum in code&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#binary-search-correctness-proof&#34;&gt;Binary search correctness proof&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;mathematical-induction&#34;&gt;Mathematical induction&lt;/h2&gt;&#xA;&lt;p&gt;Mathematical induction is a proof method often used to prove statements about integers.&lt;/p&gt;&#xA;&lt;p&gt;We&amp;rsquo;ll use the notation P(&lt;i&gt;n&lt;/i&gt;), where &lt;i&gt;n&lt;/i&gt; ≥ 0,&#xA;to denote such a statement.&#xA;To prove P(&lt;i&gt;n&lt;/i&gt;) with induction is a two-step procedure.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Operators: complete list</title>
      <link>https://yourbasic.org/golang/operators/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/operators/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/hills_alive/5326235115 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/arithmetics-on-blackboard.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#arithmetic&#34;&gt;Arithmetic&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#comparison&#34;&gt;Comparison&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#logical&#34;&gt;Logical&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pointers-and-channels&#34;&gt;Pointers and channels&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#operator-precedence&#34;&gt;Operator precedence&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;arithmetic&#34;&gt;Arithmetic&lt;/h2&gt;&#xA;&lt;table class=&#34;white&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;Operator&lt;/th&gt;&#xA;      &lt;th&gt;Name&lt;/th&gt;&#xA;      &lt;th&gt;Types&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;&lt;code&gt;+&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td&gt;sum&lt;/td&gt;&#xA;      &lt;td&gt;integers, floats, complex values, strings&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;difference&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;integers, floats, complex values&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;product&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;/&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;quotient&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;%&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;remainder&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;integers&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;code&gt;&amp;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;bitwise AND&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;code&gt;|&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;bitwise OR&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;code&gt;^&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;bitwise XOR&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;&amp;^&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;bit clear (AND&amp;nbsp;NOT)&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;&lt;code&gt;&lt;&lt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;left shift&lt;/td&gt;&#xA;      &lt;td style=&#34;border-bottom: 0;&#34;&gt;integer &lt;&lt; unsigned integer&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;&lt;code&gt;&gt;&gt;&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;right shift&lt;/td&gt;&#xA;      &lt;td style=&#34;padding-top: 0;&#34;&gt;integer &gt;&gt; unsigned integer&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://golang.org/ref/spec#Arithmetic_operators&#34;&gt;Arithmetic operators&lt;/a&gt;&#xA;in the Go language specification for complete definitions of the shift, quotient and remainder operators,&#xA;integer overflow, and floating point behavior.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Optional parameters, default parameter values and method overloading</title>
      <link>https://yourbasic.org/golang/overload-overwrite-optional-parameter/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/overload-overwrite-optional-parameter/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Junction-Away-Decision-Direction-Fork-In-The-Road-1020088 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/decision-fork-in-the-road.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;By design, Go does &lt;strong&gt;not&lt;/strong&gt; support&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;optional parameters&lt;/strong&gt;,&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;default parameter values&lt;/strong&gt;,&lt;/li&gt;&#xA;&lt;li&gt;or &lt;strong&gt;method overloading&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Method dispatch is simplified if it doesn&amp;rsquo;t need to do type matching as well.&#xA;Experience with other languages told us that having a variety of methods&#xA;with the same name but different signatures was occasionally useful&#xA;but that it could also be confusing and fragile in practice.&#xA;Matching only by name and requiring consistency in the types&#xA;was a major simplifying decision in Go&amp;rsquo;s type system.&#xA;&lt;a class=&#34;quote-source&#34; href=&#34;https://golang.org/doc/faq#overloading&#34;&gt;Go FAQ: Why does Go not support overloading of methods and operators?&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Package documentation</title>
      <link>https://yourbasic.org/golang/package-documentation/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/package-documentation/</guid>
      <description>&lt;!-- CC BY 3.0: https://golang.org/doc/gopher/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/ref.png&#34; style=&#34;float: right; margin: 0 0 25px 10px;&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#godoc-org-website&#34;&gt;godoc.org website&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#local-godoc-server&#34;&gt;Local godoc server&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#go-doc-command-line-tool&#34;&gt;go doc command-line tool&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#create-documentation&#34;&gt;Create documentation&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#runnable-documentation-examples&#34;&gt;Runnable documentation examples&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;godocorg-website&#34;&gt;godoc.org website&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://godoc.org/&#34;&gt;GoDoc&lt;/a&gt; website hosts docu­men­tation for all public&#xA;Go &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;packages&lt;/a&gt; on Bitbucket, GitHub, Google Project Hosting and Launchpad.&lt;/p&gt;&#xA;&lt;h2 id=&#34;local-godoc-server&#34;&gt;Local godoc server&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://godoc.org/golang.org/x/tools/cmd/godoc&#34;&gt;godoc&lt;/a&gt; command&#xA;extracts and generates documentation for all locally installed Go programs,&#xA;both your own code and the standard libraries.&lt;/p&gt;&#xA;&lt;p&gt;The following command starts a web server that presents the documentation&#xA;at &lt;code&gt;http://localhost:6060/&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Package initialization and program execution order</title>
      <link>https://yourbasic.org/golang/package-init-function-main-execution-order/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/package-init-function-main-execution-order/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/formation-migratory-birds-geese-508038/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/birds-in-formation.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#program-execution&#34;&gt;Program execution&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#package-initialization&#34;&gt;Package initialization&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#init-function&#34;&gt;Init function&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#warning&#34;&gt;Warning&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First the &lt;code&gt;main&lt;/code&gt; &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;package&lt;/a&gt; is initialized.&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Imported packages are initialized before the package itself.&lt;/li&gt;&#xA;&lt;li&gt;Packages are initialized one at a time:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;first package-level variables are initialized in declaration order,&lt;/li&gt;&#xA;&lt;li&gt;then the &lt;code&gt;init&lt;/code&gt; functions are run.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Finally the &lt;code&gt;main&lt;/code&gt; function is called.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;program-execution&#34;&gt;Program execution&lt;/h2&gt;&#xA;&lt;p&gt;Program execution begins by initializing the &lt;code&gt;main&lt;/code&gt; package and&#xA;then calling the function &lt;code&gt;main&lt;/code&gt;.&#xA;When &lt;code&gt;main&lt;/code&gt; returns, the program exits.&#xA;It &lt;b&gt;does not wait&lt;/b&gt; for other goroutines to complete.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Packages explained: declare, import, download, document</title>
      <link>https://yourbasic.org/golang/packages-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/packages-explained/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:Paket_med_hagel_fr%C3%A5n_Sala_silvergruva_-_Livrustkammaren_-_31089.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/paket.jpg&#34; class=&#34;extra-content&#34; style=&#34;float: right; margin: 0 0 25px 0;&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#declare-a-package&#34;&gt;Declare a package&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#package-name-conflicts&#34;&gt;Package name conflicts&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#dot-imports&#34;&gt;Dot imports&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#package-download&#34;&gt;Package download&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#package-documentation&#34;&gt;Package documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;Every Go program is made up of packages and each package has an &lt;strong&gt;import path&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;fmt&amp;quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;math/rand&amp;quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;&amp;quot;github.com/yourbasic/graph&amp;quot;&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Packages in the standard library have short import paths,&#xA;such as &lt;code&gt;&amp;quot;fmt&amp;quot;&lt;/code&gt; and &lt;code&gt;&amp;quot;math/rand&amp;quot;&lt;/code&gt;.&#xA;Third-party packages, such as &lt;code&gt;&amp;quot;github.com/yourbasic/graph&amp;quot;&lt;/code&gt;, typically have an import path&#xA;that includes a hosting service (&lt;code&gt;github.com&lt;/code&gt;) and an organization name (&lt;code&gt;yourbasic&lt;/code&gt;).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Panics, stack traces and how to recover [best practice]</title>
      <link>https://yourbasic.org/golang/recover-from-panic/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/recover-from-panic/</guid>
      <description>&lt;!-- CC0:  https://pixabay.com/en/terrorist-terror-happiness-positive-2481808/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/panic.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin-top:1em;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#a-panic-is-an-exception-in-go&#34;&gt;A panic is an exception in Go&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#stack-traces&#34;&gt;Stack traces&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#interpret-a-stack-trace&#34;&gt;Interpret a stack trace&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#print-and-log-a-stack-trace&#34;&gt;Print and log a stack trace&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#level-of-detail&#34;&gt;Level of detail&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#recover-and-catch-a-panic&#34;&gt;Recover and catch a panic&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#panic-handler-example&#34;&gt;Panic handler example&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#return-a-value&#34;&gt;Return a value&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#test-a-panic-utility-function&#34;&gt;Test a panic (utility function)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;a-panic-is-an-exception-in-go&#34;&gt;A panic is an exception in Go&lt;/h2&gt;&#xA;&lt;p&gt;Panics are similar to C++ and Java exceptions,&#xA;but are only intended for run-time errors,&#xA;such as following a nil pointer or attempting to index an array out of bounds.&#xA;To signify events such as end-of-file, Go programs use the built-in &lt;code&gt;error&lt;/code&gt; type.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/errors-explained/&#34;&gt;Error handling best practice&lt;/a&gt; and &lt;a href=&#34;https://yourbasic.org/golang/create-error/&#34;&gt;3 simple ways to create an error&lt;/a&gt; for more on errors.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pass a slice to a variadic function</title>
      <link>https://yourbasic.org/golang/pass-slice-to-variadic-function/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/pass-slice-to-variadic-function/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/variadic-function/&#34;&gt;Variadic functions (&amp;hellip;T)&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pick the right one: int vs. int64</title>
      <link>https://yourbasic.org/golang/int-vs-int64/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/int-vs-int64/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/house-houses-spot-the-difference-3208132/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/spot-difference.png&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;use-int-for-indexing&#34;&gt;Use int for indexing&lt;/h2&gt;&#xA;&lt;p&gt;An &lt;strong&gt;index&lt;/strong&gt;, &lt;strong&gt;length&lt;/strong&gt; or &lt;strong&gt;capacity&lt;/strong&gt; should normally be an &lt;code&gt;int&lt;/code&gt;.&#xA;The &lt;code&gt;int&lt;/code&gt; type is either 32 or 64 bits, and always big enough&#xA;to hold the maximum possible length of an array.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/max-min-int-uint/&#34;&gt;Maximum value of an int&lt;/a&gt; for code&#xA;to compute the maximum value of an &lt;code&gt;int&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;use-int64-and-friends-for-data&#34;&gt;Use int64 and friends for data&lt;/h2&gt;&#xA;&lt;p&gt;The types &lt;code&gt;int8&lt;/code&gt;, &lt;code&gt;int16&lt;/code&gt;, &lt;code&gt;int32&lt;/code&gt;, and &lt;code&gt;int64&lt;/code&gt; (and their&#xA;unsigned counterparts) are best suited for &lt;strong&gt;data&lt;/strong&gt;.&#xA;An &lt;code&gt;int64&lt;/code&gt; is the typical choice when memory isn&amp;rsquo;t an issue.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pointer vs. value receiver</title>
      <link>https://yourbasic.org/golang/pointer-vs-value-receiver/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/pointer-vs-value-receiver/</guid>
      <description>&lt;!-- Public domain: https://en.wikipedia.org/wiki/File:Ducreux1.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/pointing-man.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;basic-guidelines&#34;&gt;Basic guidelines&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;For a given type, &lt;em&gt;don&amp;rsquo;t mix&lt;/em&gt; value and pointer receivers.&lt;/li&gt;&#xA;&lt;li&gt;If in doubt, &lt;em&gt;use pointer receivers&lt;/em&gt; (they are safe and extendable).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;pointer-receivers&#34;&gt;Pointer receivers&lt;/h2&gt;&#xA;&lt;p&gt;You &lt;em&gt;must&lt;/em&gt; use pointer receivers&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if any method needs to mutate the receiver,&lt;/li&gt;&#xA;&lt;li&gt;for structs that contain a &lt;code&gt;sync.Mutex&lt;/code&gt; or similar synchronizing field&#xA;(they musn&amp;rsquo;t be copied).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;You &lt;em&gt;probably want&lt;/em&gt; to use pointer receivers&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;for large structs or arrays (it can be more efficient),&lt;/li&gt;&#xA;&lt;li&gt;in all other cases.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;value-receivers&#34;&gt;Value receivers&lt;/h2&gt;&#xA;&lt;p&gt;You &lt;em&gt;probably want&lt;/em&gt; to use value receivers&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pointers explained</title>
      <link>https://yourbasic.org/golang/pointers-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/pointers-explained/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/pointing-finger-hand-pointing-1922074/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/pointing-finger.png&#34; style=&#34;float: right; margin: 10px 0 10px 10px;&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;A pointer is a vari&amp;shy;able that con&amp;shy;tains the address of an&amp;nbsp;object.&lt;/p&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#address-operator&#34;&gt;Address operator&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pointer-indirection&#34;&gt;Pointer indirection&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pointers-as-parameters&#34;&gt;Pointers as parameters&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;Structs and arrays are &lt;strong&gt;copied&lt;/strong&gt; when used in assignments and passed as arguments to functions. With pointers this can be avoided.&lt;/p&gt;&#xA;&lt;p&gt;Pointers store &lt;strong&gt;addresses&lt;/strong&gt; of objects.&#xA;The addresses can be passed around more efficiently than the actual objects.&lt;/p&gt;&#xA;&lt;p&gt;A pointer has type &lt;code&gt;*T&lt;/code&gt;.&#xA;The keyword &lt;code&gt;new&lt;/code&gt; allocates a new object and returns its address.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Print null in Java</title>
      <link>https://yourbasic.org/print-null-java/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/print-null-java/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;What happens if you try to print null in&amp;nbsp;Java?&#xA;It&amp;nbsp;depends.&#xA;&lt;/p&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/res/programmer.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;what-the-compiler-said&#34;&gt;What the compiler said&lt;/h2&gt;&#xA;&lt;p&gt;The following line will &lt;strong&gt;not compile&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&#xA;System.out.println(null);&#xA;&lt;/pre&gt;&#xA;&lt;p&gt;&#xA;This is the message from my compiler.&#xA;&lt;/p&gt;&#xA;&lt;pre&gt;&#xA;reference to println is ambiguous, both&#xA;method println(char[]) in java.io.PrintStream and&#xA;method println(java.lang.String) in java.io.PrintStream match&#xA;&lt;/pre&gt;&#xA;&lt;p&gt;In fact, &lt;code&gt;println(java.lang.Object)&lt;/code&gt; in &lt;code&gt;java.io.PrintStream&lt;/code&gt;&#xA;is yet another match,&#xA;but Java has a way of choosing between that one and each of the two methods above.&#xA;It’s just the string and the character array parameters&#xA;that cause ambiguity; character arrays and objects can happily coexist.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Professor Nilssons fuskföreläsning</title>
      <link>https://yourbasic.org/fusk/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/fusk/</guid>
      <description>&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/res/cardsharps.jpg&#34; alt=&#34;Cardsharps, Caravaggio c. 1594.&#34; title=&#34;Cardsharps, Caravaggio c. 1594.&#34;&gt;&lt;/div&gt;&#xA;&lt;blockquote&gt;&#xA;Den går man på.&lt;br&gt;&#xA; &amp;ndash; Okänd student på KTH&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;Dafaq did I just see?&lt;br&gt;&#xA; &amp;ndash; Anton Lövmar &lt;span style=&#34;color:grey;font-size:90%;&#34;&gt;3 Sep 2012&lt;/span&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;Otroligt rolig och underhållande förställning. Fattar&amp;nbsp;ingenting.&lt;br&gt;&#xA; &amp;ndash; Mattias Folke &lt;span style=&#34;color:grey;font-size:90%;&#34;&gt;17 Okt 2013&lt;/span&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;om-föreställningen&#34;&gt;Om föreställningen&lt;/h2&gt;&#xA;&lt;p&gt;Professor Nilsson lär dig fuska i en föreställning&#xA;med många överraskningar och goda skratt.&lt;/p&gt;&#xA;&lt;p&gt;Till skillnad från andra korthajar så hjälper professorn&#xA;sina medspelare att vinna. Alla som varit modiga&#xA;nog att spela kort med Professor Nilsson&#xA;har slutat som segrare och fått utmärkta betyg.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Public vs. private</title>
      <link>https://yourbasic.org/golang/public-private/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/public-private/</guid>
      <description>&lt;!-- CC0: http://www.publicdomainpictures.net/view-image.php?image=23003 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/private.jpg&#34; class=&#34;extra-content&#34; alt=&#34;PRIVATE KEEP OUT&#34; style=&#34;float: right; margin: 20px 0 0 20px;&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;A package is the smallest unit of private encap&amp;shy;sulation in&amp;nbsp;Go.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;All identifiers defined within a &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;package&lt;/a&gt; are visible throughout that package.&lt;/li&gt;&#xA;&lt;li&gt;When importing a package you can access only its &lt;strong&gt;exported&lt;/strong&gt; identifiers.&lt;/li&gt;&#xA;&lt;li&gt;An identifier is exported if it begins with a &lt;strong&gt;capital letter&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Exported and unexported identifiers are used to describe the public interface of a package&#xA;and to guard against certain programming errors.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Quicksort optimizations explained [complete code]</title>
      <link>https://yourbasic.org/golang/quicksort-optimizations/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/quicksort-optimizations/</guid>
      <description>&lt;!-- CC BY 2.0:https://www.flickr.com/photos/nicola_s/20141007433 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/divide-conquer.jpg&#34; class=&#34;extra-content&#34; style=&#34;float: right; margin: 20px 0 0 20px;&#34; alt=&#34;Quicksort is a divide-and-conquer algorithm&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;Most Quicksort optimi&amp;shy;zations give only small improve&amp;shy;ments.&#xA;Here&amp;nbsp;are three that can make a&amp;nbsp;real differ&amp;shy;ence.&lt;/p&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#algorithm-overview&#34;&gt;Algorithm overview&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pivot-element&#34;&gt;Pivot element&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#3-way-partition&#34;&gt;3-way partition&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#combining-algorithms&#34;&gt;Combining algorithms&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;algorithm-overview&#34;&gt;Algorithm overview&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Pick an element &lt;code&gt;p&lt;/code&gt;, called a pivot, from the list.&lt;/li&gt;&#xA;&lt;li&gt;Partition the list so that&#xA;&lt;ul&gt;&#xA;&lt;li&gt;all elements less than &lt;code&gt;p&lt;/code&gt; come first,&lt;/li&gt;&#xA;&lt;li&gt;all elements greater than &lt;code&gt;p&lt;/code&gt; come last,&lt;/li&gt;&#xA;&lt;li&gt;elements equal to &lt;code&gt;p&lt;/code&gt; go into the middle.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;Recursively apply the above steps to the sublists of small and large elements.&lt;/li&gt;&#xA;&lt;li&gt;For short sublists, use a simpler sorting algorithm.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;//  Quicksort sorts the elements of v in ascending order.&#xA;func Quicksort(v []int) {&#xA;&#x9;if len(v) &lt; 20 {&#xA;&#x9;&#x9;InsertionSort(v)&#xA;&#x9;&#x9;return&#xA;&#x9;}&#xA;&#x9;p := Pivot(v)&#xA;&#x9;low, high := Partition(v, p)&#xA;&#x9;Quicksort(v[:low])&#xA;&#x9;Quicksort(v[high:])&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;With some ingenuity this algorithm can be implemented to run very fast.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Radix sorting basics</title>
      <link>https://yourbasic.org/algorithms/radix-sort/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/radix-sort/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Radix sorting is a simple and efficient sorting method that sometimes outperforms comparison-based algorithms.&lt;/p&gt;&#xA;&lt;!-- Public Domain Mark 1.0: https://picryl.com/media/sorting-mail --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/sorting-mail.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#bucket-sort&#34;&gt;Bucket sort&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#lsd-radix-sort&#34;&gt;LSD radix sort&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#msd-radix-sort&#34;&gt;MSD radix sort&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Radix sort is a non-comparative sorting algorithm for sorting numbers or strings. It distributes elements into buckets according to the digits of the numbers or the characters of the strings.&lt;/p&gt;&#xA;&lt;h2 id=&#34;bucket-sort&#34;&gt;Bucket sort&lt;/h2&gt;&#xA;&lt;p&gt;Bucket sort is the basic building block of most radix sorting schemes.&#xA;It solves the special case of sorting&#xA;&lt;i&gt;n&lt;/i&gt; integers drawn from a small set {0, 1, …, &lt;i&gt;m&lt;/i&gt;-1}.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Read a file (stdin) line by line</title>
      <link>https://yourbasic.org/golang/read-file-line-by-line/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/read-file-line-by-line/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/1105803 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/boy-reading-book.png&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#read-from-file&#34;&gt;Read from file&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#read-from-stdin&#34;&gt;Read from stdin&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#read-from-any-stream&#34;&gt;Read from any stream&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;read-from-file&#34;&gt;Read from file&lt;/h2&gt;&#xA;&lt;p&gt;Use a &lt;a href=&#34;https://golang.org/pkg/bufio/#Scanner&#34;&gt;&lt;code&gt;bufio.Scanner&lt;/code&gt;&lt;/a&gt; to read a file line by line.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;file, err := os.Open(&#34;file.txt&#34;)&#xA;if err != nil {&#xA;&#x9;log.Fatal(err)&#xA;}&#xA;defer file.Close()&#xA;&#xA;scanner := bufio.NewScanner(file)&#xA;for scanner.Scan() {&#xA;&#x9;fmt.Println(scanner.Text())&#xA;}&#xA;&#xA;if err := scanner.Err(); err != nil {&#xA;&#x9;log.Fatal(err)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;read-from-stdin&#34;&gt;Read from stdin&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/os/#pkg-variables&#34;&gt;&lt;code&gt;os.Stdin&lt;/code&gt;&lt;/a&gt; to read from the standard input stream.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;scanner := bufio.NewScanner(os.Stdin)&#xA;for scanner.Scan() {&#xA;&#x9;fmt.Println(scanner.Text())&#xA;}&#xA;&#xA;if err := scanner.Err(); err != nil {&#xA;&#x9;log.Println(err)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;read-from-any-stream&#34;&gt;Read from any stream&lt;/h2&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/io-reader-interface-explained/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/teddy-bear-reading-thumb.jpg&#34; title=&#34;How to use the io.Reader interface&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p&gt;A bufio.Scanner can read from any stream of bytes, as long as it implements&#xA;the &lt;a href=&#34;https://golang.org/pkg/io/#Reader&#34;&gt;&lt;code&gt;io.Reader&lt;/code&gt;&lt;/a&gt; interface.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/io-reader-interface-explained/&#34;&gt;How to use the io.Reader interface&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Redeclaring variables</title>
      <link>https://yourbasic.org/golang/redeclaring-variables/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/redeclaring-variables/</guid>
      <description>&lt;p&gt;You can&amp;rsquo;t redeclare a variable which has already been declared in the same block.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func main() {&#xA;&#x9;m := 0&#xA;&#x9;m := 1&#xA;&#x9;fmt.Println(m)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:3:4: no new variables on left side of :=&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;However, variables can be redeclared in short multi-variable declarations&#xA;where at least one new variable is introduced.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;func main() {&#xA;&#x9;m := 0&#xA;&#x9;m, n := 1, 2&#xA;&#x9;fmt.Println(m, n)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;&#xA;&lt;p&gt;Unlike regular variable declarations, a short variable declaration may redeclare&#xA;variables provided they were originally declared earlier in the same block&#xA;(or the parameter lists if the block is the function body)&#xA;with the same type, and at least one of the non-blank variables is new. [&amp;hellip;]&#xA;Redeclaration does not introduce a new variable; it just assigns a new value to the original.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Regexp tutorial and cheat sheet</title>
      <link>https://yourbasic.org/golang/regexp-cheat-sheet/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/regexp-cheat-sheet/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A regular expression is a sequence of characters that define a&amp;nbsp;search pattern.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pxhere.com/en/photo/1372296 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/cog-wheels.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&#xA;&lt;div style=&#34;float: left; min-width: 40%; margin-right: 2em;&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin:0;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#compile&#34;&gt;Compile&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#raw-strings&#34;&gt;Raw strings&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#cheat-sheet&#34;&gt;Cheat sheet&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#choice-and-grouping&#34;&gt;Choice and grouping&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#repetition-greedy-and-non-greedy&#34;&gt;Repetition (greedy and non-greedy)&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#character-classes&#34;&gt;Character classes&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#special-characters&#34;&gt;Special characters&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#text-boundary-anchors&#34;&gt;Text boundary anchors&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#case-insensitive-and-multiline-matches&#34;&gt;Case-insensitive and multiline matches&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left;&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin:0;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#code-examples&#34;&gt;Code examples&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#first-match&#34;&gt;First match&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#location&#34;&gt;Location&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#all-matches&#34;&gt;All matches&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#replace&#34;&gt;Replace&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#split&#34;&gt;Split&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#implementation&#34;&gt;Implementation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;The regular expression &lt;code&gt;a.b&lt;/code&gt; matches any string that&#xA;starts with an &lt;code&gt;a&lt;/code&gt;, ends with a &lt;code&gt;b&lt;/code&gt;,&#xA;and has a single character in between (the period matches any character).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Remove all duplicate whitespace</title>
      <link>https://yourbasic.org/golang/remove-duplicate-whitespace/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/remove-duplicate-whitespace/</guid>
      <description>&lt;pre&gt;&lt;code&gt;space := regexp.MustCompile(`\s+`)&#xA;s := space.ReplaceAllString(&#34;Hello  \t \n world!&#34;, &#34; &#34;)&#xA;fmt.Printf(&#34;%q&#34;, s) &lt;span class=&#34;comment&#34;&gt;// &#34;Hello world!&#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;code&gt;\s+&lt;/code&gt; is a &lt;a href=&#34;https://yourbasic.org/golang/regexp-cheat-sheet/&#34;&gt;regular expression&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the character class &lt;code&gt;\s&lt;/code&gt; matches a space, tab, new line, carriage return or form feed,&lt;/li&gt;&#xA;&lt;li&gt;and &lt;code&gt;+&lt;/code&gt; says “one or more of those”.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;In other words, the code will replace each whitespace substring with a single space character.&lt;/p&gt;&#xA;&lt;h3 id=&#34;trim-leading-and-trailing-space&#34;&gt;Trim leading and trailing space&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/trim-whitespace-from-string/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/trim-hair-thumb.jpg&#34; title=&#34;Trim leading and trailing whitespace&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p&gt;To &lt;a href=&#34;https://yourbasic.org/golang/trim-whitespace-from-string/&#34;&gt;trim leading and trailing whitespace&lt;/a&gt;, use the &lt;code&gt;strings.TrimSpace&lt;/code&gt; function.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Round float to 2 decimal places</title>
      <link>https://yourbasic.org/golang/round-float-2-decimal-places/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/round-float-2-decimal-places/</guid>
      <description>&lt;h2 id=&#34;float-to-string&#34;&gt;Float to string&lt;/h2&gt;&#xA;&lt;p&gt;To display the value as a string, use the &lt;a href=&#34;https://golang.org/pkg/fmt/#Sprintf&#34;&gt;&lt;code&gt;fmt.Sprintf&lt;/code&gt;&lt;/a&gt; method.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := fmt.Sprintf(&#34;%.2f&#34;, 12.3456) &lt;span class=&#34;comment&#34;&gt;// s == &#34;12.35&#34;&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://yourbasic.org/golang/fmt-printf-reference-cheat-sheet/&#34;&gt;fmt cheat sheet&lt;/a&gt; lists the most common formatting verbs and flags.&lt;/p&gt;&#xA;&lt;h2 id=&#34;float-to-float&#34;&gt;Float to float&lt;/h2&gt;&#xA;&lt;p&gt;To round to a floating-point value, use one of these techniques.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x := 12.3456&#xA;fmt.Println(math.Floor(x*100)/100) &lt;span class=&#34;comment&#34;&gt;// 12.34 (round down)&lt;/span&gt;&#xA;fmt.Println(math.Round(x*100)/100) &lt;span class=&#34;comment&#34;&gt;// 12.35 (round to nearest)&lt;/span&gt;&#xA;fmt.Println(math.Ceil(x*100)/100)  &lt;span class=&#34;comment&#34;&gt;// 12.35 (round up)&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Due to the quirks of floating point representation,&#xA;these rounded values may be slightly off.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Round float to integer value</title>
      <link>https://yourbasic.org/golang/round-float-to-int/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/round-float-to-int/</guid>
      <description>&lt;ul class=&#34;toc&#34;&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#round-away-from-zero&#34;&gt;Round away from zero&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#round-to-even-number&#34;&gt;Round to even number&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#convert-to-an-int-type&#34;&gt;Convert to an int type&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#before-go-1-10&#34;&gt;Before Go 1.10&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;round-away-from-zero&#34;&gt;Round away from zero&lt;span class=&#34;quicklink&#34;&gt;&lt;a href=&#34;https://golang.org/doc/go1.10&#34; title=&#34;Go 1.10 Release Notes&#34;&gt;Go&amp;nbsp;1.10&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/math/#Round&#34;&gt;&lt;code&gt;math.Round&lt;/code&gt;&lt;/a&gt;&#xA;to return the nearest integer, as a &lt;code&gt;float64&lt;/code&gt;, rounding ties away from zero.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Println(math.Round(-0.6)) &lt;span class=&#34;comment&#34;&gt;// -1&lt;/span&gt;&#xA;fmt.Println(math.Round(-0.4)) &lt;span class=&#34;comment&#34;&gt;// -0&lt;/span&gt;&#xA;fmt.Println(math.Round(0.4))  &lt;span class=&#34;comment&#34;&gt;// 0&lt;/span&gt;&#xA;fmt.Println(math.Round(0.6))  &lt;span class=&#34;comment&#34;&gt;// 1&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Note the special cases.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Round(±0) = ±0&#xA;Round(±Inf) = ±Inf&#xA;Round(NaN) = NaN&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;round-to-even-number&#34;&gt;Round to even number&lt;span class=&#34;quicklink&#34;&gt;&lt;a href=&#34;https://golang.org/doc/go1.10&#34; title=&#34;Go 1.10 Release Notes&#34;&gt;Go&amp;nbsp;1.10&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Use &lt;a href=&#34;https://golang.org/pkg/math/#RoundToEven&#34;&gt;&lt;code&gt;math.RoundToEven&lt;/code&gt;&lt;/a&gt;&#xA;to return the nearest integer, as a &lt;code&gt;float64&lt;/code&gt;, rounding ties to an even number.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Runes and character encoding</title>
      <link>https://yourbasic.org/golang/rune/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/rune/</guid>
      <description>&lt;!-- No copyright: https://www.flickr.com/photos/34419668@N08/5435942992 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/rune-stone-ballstorp-1900.jpg&#34; alt=&#34;Runic letters encoded in stone&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;font-size:smaller;&#34;&gt;Runic letters encoded in stone, Ballstorp 1900&lt;/div&gt;&#xA;&lt;h2 id=&#34;characters-ascii-and-unicode&#34;&gt;Characters, ASCII and Unicode&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;code&gt;rune&lt;/code&gt; type is an alias for &lt;code&gt;int32&lt;/code&gt;, and is used to emphasize&#xA;than an integer represents a code point.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;strong&gt;ASCII&lt;/strong&gt; defines 128 characters, identified by the &lt;strong&gt;code points&lt;/strong&gt; 0–127.&#xA;It covers English letters, Latin numbers, and a few other characters.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Unicode&lt;/strong&gt;, which is a superset of ASCII, defines a codespace of 1,114,112 code points.&#xA;Unicode version 10.0 covers 139 modern and historic scripts (including the runic alphabet, but not Klingon)&#xA;as well as multiple symbol sets.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Select waits on a group of channels</title>
      <link>https://yourbasic.org/golang/select-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/select-explained/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://commons.wikimedia.org/wiki/File:Bluewater3753.JPG --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/select-sushi.jpg&#34;/&gt;&lt;/div&gt;&#xA;&lt;p&gt;The select statement waits for multiple send or receive opera­tions simul­taneously.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The statement blocks as a whole until one of the operations becomes unblocked.&lt;/li&gt;&#xA;&lt;li&gt;If several cases can proceed, a single one of them will be chosen at random.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;&lt;span class=&#34;comment&#34;&gt;// blocks until there&#39;s data available on ch1 or ch2&lt;/span&gt;&#xA;select {&#xA;case &lt;-ch1:&#xA;&#x9;fmt.Println(&#34;Received from ch1&#34;)&#xA;case &lt;-ch2:&#xA;&#x9;fmt.Println(&#34;Received from ch2&#34;)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Send and receive operations on a &lt;code&gt;nil&lt;/code&gt; channel block forever.&#xA;This can be used to disable a channel in a select statement:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Shadowed variables</title>
      <link>https://yourbasic.org/golang/gotcha-shadowing-variables/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-shadowing-variables/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/1169066 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/man-in-shadow.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t &lt;code&gt;n&lt;/code&gt; change?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;n := 0&#xA;&#x9;if true {&#xA;&#x9;&#x9;n := 1&#xA;&#x9;&#x9;n++&#xA;&#x9;}&#xA;&#x9;fmt.Println(n) &lt;span class=&#34;comment&#34;&gt;// 0&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The statement &lt;code&gt;n := 1&lt;/code&gt; declares a new variable which &lt;strong&gt;shadows&lt;/strong&gt; the original &lt;code&gt;n&lt;/code&gt; throughout the scope of the if&amp;nbsp;statement.&lt;/p&gt;&#xA;&lt;p&gt;To reuse &lt;code&gt;n&lt;/code&gt; from the outer block, write &lt;code&gt;n = 1&lt;/code&gt; instead.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;n := 0&#xA;&#x9;if true {&#xA;&#x9;&#x9;&lt;b&gt;n = 1&lt;/b&gt;&#xA;&#x9;&#x9;n++&#xA;&#x9;}&#xA;&#x9;fmt.Println(n) &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;2&lt;/b&gt;&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;detecting-shadowed-variables&#34;&gt;Detecting shadowed variables&lt;/h2&gt;&#xA;&lt;p&gt;To help detect shadowed variables, you may use the experimental &lt;code&gt;-shadow&lt;/code&gt; feature provided by the &lt;a href=&#34;https://golang.org/cmd/vet/&#34;&gt;vet&lt;/a&gt; tool. It flags variables that &lt;strong&gt;may have been&lt;/strong&gt; unintentionally shadowed. Passing the original version of the code to &lt;code&gt;vet&lt;/code&gt; gives a warning message.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Shuffle a slice or array</title>
      <link>https://yourbasic.org/golang/shuffle-slice-array/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/shuffle-slice-array/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://en.wikipedia.org/wiki/File:Riffle_shuffle.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/riffle-shuffle.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://golang.org/pkg/math/rand/#Shuffle&#34;&gt;&lt;code&gt;rand.Shuffle&lt;/code&gt;&lt;/a&gt; function&#xA;in package &lt;a href=&#34;https://golang.org/pkg/math/rand/&#34;&gt;&lt;code&gt;math/rand&lt;/code&gt;&lt;/a&gt;&#xA;shuffles an input sequence using a given swap function.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;a := []int{1, 2, 3, 4, 5, 6, 7, 8}&#xA;rand.Seed(time.Now().UnixNano())&#xA;rand.Shuffle(len(a), func(i, j int) { a[i], a[j] = a[j], a[i] })&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[5 8 6 4 3 7 2 1]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; Without the call to &lt;code&gt;rand.Seed&lt;/code&gt; you will get&#xA;the same sequence of pseudo&amp;shy;random numbers each time you run the program.&#xA;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;further-reading&#34;&gt;Further reading&lt;/h3&gt;&#xA;&lt;div&gt;&lt;a href=&#34;https://yourbasic.org/golang/generate-number-random-range/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/dart-thumb.jpg&#34; title=&#34;Generate random numbers, characters and slice elements&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p style=&#34;margin-top:0; margin-bottom:2em;&#34;&gt;&lt;a href=&#34;https://yourbasic.org/golang/generate-number-random-range/&#34;&gt;Generate random numbers, characters and slice elements&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Slices/arrays explained: create, index, slice, iterate</title>
      <link>https://yourbasic.org/golang/slices-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/slices-explained/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/orange-food-juicy-fruit-188082/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/orange.jpg&#34; alt=&#34;A sliced orange&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;margin-top: 1em&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left; min-width: 20%; margin-right: 2em;&#34;&gt;&#xA;  &lt;ul class=&#34;toc&#34; style=&#34;margin: 0;&#34;&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#construction&#34;&gt;Construction&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#slicing&#34;&gt;Slicing&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left;&#34;&gt;&#xA;  &lt;ul class=&#34;toc&#34; style=&#34;margin: 0;&#34;&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#iteration&#34;&gt;Iteration&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#append-and-copy&#34;&gt;Append and copy&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;li&gt;&lt;a href=&#34;#stacks-and-queues&#34;&gt;Stacks and queues&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;A slice doesn&amp;rsquo;t store any data, it just describes&#xA;a section of an underlying &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-arrays/&#34;&gt;array&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When you change an element of a slice, you modify the corresponding element of its underlying array,&#xA;and other slices that share the same underlying array will see the change.&lt;/li&gt;&#xA;&lt;li&gt;A slice can grow and shrink within the bounds of the underlying array.&lt;/li&gt;&#xA;&lt;li&gt;Slices are indexed in the usual way: &lt;code&gt;s[i]&lt;/code&gt; accesses&#xA;the &lt;code&gt;i&lt;/code&gt;th element, starting from zero.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;construction&#34;&gt;Construction&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;var s []int                   &lt;span class=&#34;comment&#34;&gt;// a nil slice&lt;/span&gt;&#xA;s1 := []string{&#34;foo&#34;, &#34;bar&#34;}&#xA;s2 := make([]int, 2)          &lt;span class=&#34;comment&#34;&gt;// same as []int{0, 0}&lt;/span&gt;&#xA;s3 := make([]int, 2, 4)       &lt;span class=&#34;comment&#34;&gt;// same as new([4]int)[:2]&lt;/span&gt;&#xA;fmt.Println(len(s3), cap(s3)) &lt;span class=&#34;comment&#34;&gt;// 2 4&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;The default &lt;strong&gt;zero value&lt;/strong&gt; of a slice is &lt;code&gt;nil&lt;/code&gt;.&#xA;The functions &lt;code&gt;len&lt;/code&gt;, &lt;code&gt;cap&lt;/code&gt; and &lt;code&gt;append&lt;/code&gt;&#xA;all regard &lt;code&gt;nil&lt;/code&gt; as an empty slice with 0 capacity.&lt;/li&gt;&#xA;&lt;li&gt;You create a slice either by a &lt;strong&gt;slice literal&lt;/strong&gt; or&#xA;a call to the &lt;a href=&#34;https://golang.org/pkg/builtin/#make&#34;&gt;&lt;code&gt;make&lt;/code&gt;&lt;/a&gt; function,&#xA;which takes the &lt;strong&gt;length&lt;/strong&gt; and an optional &lt;strong&gt;capacity&lt;/strong&gt; as arguments.&lt;/li&gt;&#xA;&lt;li&gt;The built-in &lt;a href=&#34;https://golang.org/pkg/builtin/#len&#34;&gt;&lt;code&gt;len&lt;/code&gt;&lt;/a&gt; and&#xA;&lt;a href=&#34;https://golang.org/pkg/builtin/#cap&#34;&gt;&lt;code&gt;cap&lt;/code&gt;&lt;/a&gt; functions&#xA;retrieve the length and capacity.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;slicing&#34;&gt;Slicing&lt;/h2&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := [...]int{0, 1, 2, 3} &lt;span class=&#34;comment&#34;&gt;// an array&lt;/span&gt;&#xA;s := a[1:3]               &lt;span class=&#34;comment&#34;&gt;// s == []int{1, 2}        cap(s) == 3&lt;/span&gt;&#xA;s = a[:2]                 &lt;span class=&#34;comment&#34;&gt;// s == []int{0, 1}        cap(s) == 4&lt;/span&gt;&#xA;s = a[2:]                 &lt;span class=&#34;comment&#34;&gt;// s == []int{2, 3}        cap(s) == 2&lt;/span&gt;&#xA;s = a[:]                  &lt;span class=&#34;comment&#34;&gt;// s == []int{0, 1, 2, 3}  cap(s) == 4&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;You can also create a slice by slicing an existing array or slice.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sort a map by key or value</title>
      <link>https://yourbasic.org/golang/sort-map-keys-values/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/sort-map-keys-values/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;A &lt;a href=&#34;https://yourbasic.org/golang/maps-explained/&#34;&gt;map&lt;/a&gt; is an &lt;strong&gt;unordered&lt;/strong&gt; collection of key-value pairs.&lt;/li&gt;&#xA;&lt;li&gt;If you need a stable iteration order,&#xA;you must maintain a separate data structure.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This example uses a sorted slice of keys to print a &lt;code&gt;map[string]int&lt;/code&gt; in key order.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;m := map[string]int{&amp;#34;Alice&amp;#34;: 23, &amp;#34;Eve&amp;#34;: 2, &amp;#34;Bob&amp;#34;: 25}&#xA;&#xA;keys := make([]string, 0, len(m))&#xA;for k := range m {&#xA;&#x9;keys = append(keys, k)&#xA;}&#xA;sort.Strings(keys)&#xA;&#xA;for _, k := range keys {&#xA;&#x9;fmt.Println(k, m[k])&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Output:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Stack traces in detail</title>
      <link>https://yourbasic.org/golang/stack-trace/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/stack-trace/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/recover-from-panic/&#34;&gt;Recover from a panic [best practices]&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Start a new Go project [standard layout]</title>
      <link>https://yourbasic.org/golang/library-package-example-template/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/library-package-example-template/</guid>
      <description>&lt;!-- CC0:  http://maxpixel.freegreatpicture.com/Design-Pen-Pattern-Style-Set-Stencil-Retro-933150 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/stencil.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The repository at &lt;a href=&#34;https://github.com/yourbasic/fenwick&#34;&gt;github.com/yourbasic/fenwick&lt;/a&gt; is a small but complete Go library &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;package&lt;/a&gt;. It shows the structure of a basic project and can be used as a template.&lt;/p&gt;&#xA;&lt;p&gt;In addition to source code and resources, it includes&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;a &lt;a href=&#34;https://github.com/yourbasic/fenwick/blob/master/README.md&#34;&gt;README&lt;/a&gt; file with sections on&#xA;&lt;ul&gt;&#xA;&lt;li&gt;installation,&lt;/li&gt;&#xA;&lt;li&gt;documentation and&lt;/li&gt;&#xA;&lt;li&gt;compatibility policy,&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;unit tests,&lt;/li&gt;&#xA;&lt;li&gt;benchmarks,&lt;/li&gt;&#xA;&lt;li&gt;godoc links,&lt;/li&gt;&#xA;&lt;li&gt;a testable doc example and&lt;/li&gt;&#xA;&lt;li&gt;a licence.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;further-reading&#34;&gt;Further reading&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://yourbasic.org/algorithms/your-basic-api/&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/go-thumb.jpg&#34; width=&#34;250px&#34; title=&#34;Your basic API: Thoughts on effective API design&#34;&gt;&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Table-driven unit tests</title>
      <link>https://yourbasic.org/golang/table-driven-unit-test/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/table-driven-unit-test/</guid>
      <description>&lt;!-- CC BY 3.0: https://golang.org/doc/gopher/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/swim-safe.png&#34; style=&#34;float:right; margin: -25px 10px 0 0;&#34; width=&#34;90px&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Here is the code we want to test.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package search&#xA;&#xA;// Find returns the smallest index i at which x &lt;= a[i].&#xA;// If there is no such index, it returns len(a).&#xA;// The slice must be sorted in ascending order.&#xA;func Find(a []int, x int) int {&#xA;&#x9;switch len(a) {&#xA;&#x9;case 0:&#xA;&#x9;&#x9;return 0&#xA;&#x9;case 1:&#xA;&#x9;&#x9;if x &lt;= a[0] {&#xA;&#x9;&#x9;&#x9;return 0&#xA;&#x9;&#x9;}&#xA;&#x9;&#x9;return 1&#xA;&#x9;}&#xA;&#x9;mid := len(a) / 2&#xA;&#x9;if x &lt;= a[mid-1] {&#xA;&#x9;&#x9;return Find(a[:mid], x)&#xA;&#x9;}&#xA;&#x9;return mid + Find(a[mid:], x)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Put the test code in a file whose name ends with &lt;strong&gt;_test.go&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Write a function &lt;code&gt;TestXXX&lt;/code&gt; with a single argument of type&#xA;&lt;a href=&#34;https://golang.org/pkg/testing/#T&#34;&gt;&lt;code&gt;*testing.T&lt;/code&gt;&lt;/a&gt;. The test framework runs each such function.&lt;/li&gt;&#xA;&lt;li&gt;To indicate a failed test, call a failure function such as&#xA;&lt;a href=&#34;https://golang.org/pkg/testing/#T.Errorf&#34;&gt;&lt;code&gt;t.Errorf&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;package search&#xA;&#xA;&lt;b&gt;import &#34;testing&#34;&lt;/b&gt;&#xA;&#xA;var tests = []struct {&#xA;&#x9;a   []int&#xA;&#x9;x   int&#xA;&#x9;exp int&#xA;}{&#xA;&#x9;{[]int{}, 1, 0},&#xA;&#x9;{[]int{1, 2, 3, 3}, 0, 0},&#xA;&#x9;{[]int{1, 2, 3, 3}, 1, 0},&#xA;&#x9;{[]int{1, 2, 3, 3}, 2, 1},&#xA;&#x9;{[]int{1, 2, 3, 3}, 3, 3}, &lt;span class=&#34;comment&#34;&gt;// incorrect test case&lt;/span&gt;&#xA;&#x9;{[]int{1, 2, 3, 3}, 4, 4},&#xA;}&#xA;&#xA;func &lt;b&gt;TestFind(t *testing.T)&lt;/b&gt; {&#xA;&#x9;for _, e := range tests {&#xA;&#x9;&#x9;res := Find(e.a, e.x)&#xA;&#x9;&#x9;if res != e.exp {&#xA;&#x9;&#x9;&#x9;&lt;b&gt;t.Errorf&lt;/b&gt;(&#34;Find(%v, %d) = %d, expected %d&#34;,&#xA;&#x9;&#x9;&#x9;&#x9;e.a, e.x, res, e.exp)&#xA;&#x9;&#x9;}&#xA;&#x9;}&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Run the tests with &lt;a href=&#34;https://golang.org/cmd/go/#hdr-Test_packages&#34;&gt;&lt;code&gt;go test&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The 3 ways to sort in Go</title>
      <link>https://yourbasic.org/golang/how-to-sort-in-go/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/how-to-sort-in-go/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/ring-binders-aligned-organization-2654130/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/sorted-ring-binders.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#sort-a-slice-of-ints-float64s-or-strings&#34;&gt;Slice of ints, float64s or strings&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#sort-with-custom-comparator&#34;&gt;Custom comparator&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#sort-custom-data-structures&#34;&gt;Custom data structures&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#bonus-sort-a-map-by-key-or-value&#34;&gt;Bonus: Sort a map by key or value&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance-and-implementation&#34;&gt;Performance and implementation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;sort-a-slice-of-ints-float64s-or-strings&#34;&gt;Sort a slice of ints, float64s or strings&lt;/h2&gt;&#xA;&lt;p&gt;Use one of the functions&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/sort/#Ints&#34;&gt;&lt;code&gt;sort.Ints&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/sort/#Float64s&#34;&gt;&lt;code&gt;sort.Float64s&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/sort/#Strings&#34;&gt;&lt;code&gt;sort.Strings&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;s := []int{4, 2, 3, 1}&#xA;sort.Ints(s)&#xA;fmt.Println(s) // &lt;span class=&#34;comment&#34;&gt;[1 2 3 4]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Package &lt;a href=&#34;https://godoc.org/github.com/yourbasic/radix&#34;&gt;radix&lt;/a&gt; contains&#xA;a drop-in replacement for sort.Strings, which can be&#xA;more than twice as fast in some settings.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The empty interface</title>
      <link>https://yourbasic.org/golang/empty-interface/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/empty-interface/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/convert-int-to-string/&#34;&gt;Interfaces in a nutshell&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Time complexity of array/list operations [Java, Python]</title>
      <link>https://yourbasic.org/algorithms/time-complexity-arrays/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/time-complexity-arrays/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;To write fast code, you must know the difference between&#xA;constant and linear time array operations.&lt;/p&gt;&#xA;&lt;!-- CC0: https://www.pexels.com/photo/cars-high-speed-high-speed-photography-street-425277/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/scooter-vs-taxi-640.jpeg&#34; alt=&#34;Scooter overtaking taxi at high speed&#34;&gt;&lt;/div&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&#xA;&lt;div style=&#34;float: left; min-width: 40%; margin-right: 2em;&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin:0;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#array-basics&#34;&gt;Array basics&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#performance&#34;&gt;Performance&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#dynamic-array&#34;&gt;Dynamic array&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#expensive-list-operations&#34;&gt;Expensive list operations&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#expensive-java-arraylist-methods&#34;&gt;Java cheat sheet&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#expensive-python-list-operations&#34;&gt;Python cheat sheet&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;float: left;&#34;&gt;&#xA;&lt;ul class=&#34;toc&#34; style=&#34;font-weight: bold; margin:0;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#alternatives&#34;&gt;Alternatives&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#maps-and-dictionaries&#34;&gt;Maps and dictionaries&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#sorted-arrays&#34;&gt;Sorted arrays&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#linked-lists&#34;&gt;Linked lists&lt;/a&gt;&lt;/li&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#binary-search-trees&#34;&gt;Binary search trees&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;div style=&#34;clear: both&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Accidentally inefficient list code with&#xA;&lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-explained/#quadratic-time-complexity&#34;&gt;quadratic time complexity&lt;/a&gt;&#xA;is very common and can be hard to spot,&#xA;but when the list grows your code grinds to a halt.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Time complexity of recursive functions [Master theorem]</title>
      <link>https://yourbasic.org/algorithms/time-complexity-recursive-functions/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/time-complexity-recursive-functions/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;It&#39;s often possible to compute the time complexity of a recursive function&#xA;by formulating and solving a recurrence relation.&lt;/p&gt;&#xA;&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/gadl/337714905 --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/recursive-soup.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#recurrence-relation&#34;&gt;Recurrence relation (basic example)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#binary-search&#34;&gt;Binary search&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#master-theorem&#34;&gt;Master theorem&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#analysis-without-recurrence&#34;&gt;Analysis without recurrence&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This text contains a few examples and a formula, the “master theorem”,&#xA;which gives the solution to a class of recurrence relations that&#xA;often show up when analyzing recursive functions.&lt;/p&gt;&#xA;&lt;p&gt;We also show how to analyze recursive algorithms that depend on the size&#xA;and shape of a data structure.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Time is not a number</title>
      <link>https://yourbasic.org/golang/gotcha-multiply-duration-integer/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-multiply-duration-integer/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/fdecomite/406635986 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/time-is-not-a-number.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t this compile?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;n := 100&#xA;time.Sleep(n * time.Millisecond)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;invalid operation: n * time.Millisecond (mismatched types int and time.Duration)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;There is no mixing of numeric types in Go.&#xA;You can only multiply a &lt;code&gt;time.Duration&lt;/code&gt; with&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;  &lt;li&gt;another &lt;code&gt;time.Duration&lt;/code&gt;, or&lt;/li&gt;&#xA;  &lt;li&gt;an &lt;strong&gt;untyped integer&lt;/strong&gt; constant.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here are three correct examples.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;var n time.Duration = 100&#xA;time.Sleep(n * time.Millisecond)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;const n = 100&#xA;time.Sleep(n * time.Millisecond)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;time.Sleep(100 * time.Millisecond)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/untyped-constants/&#34;&gt;Untyped numeric constants with no limits&lt;/a&gt; for details about&#xA;typed and untyped integer and floating point constants and their limits.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Time zones</title>
      <link>https://yourbasic.org/golang/time-change-convert-location-timezone/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/time-change-convert-location-timezone/</guid>
      <description>&lt;!-- Public domain: https://en.wikipedia.org/wiki/File:Standard_World_Time_Zones.png --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/List_of_UTC_time_offsets&#34; title=&#34;List of UTC time offsets&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/time-zones.png&#34;&gt;&lt;/a&gt;&lt;/div&gt;&#xA;&lt;p&gt;Each &lt;a href=&#34;https://golang.org/pkg/time/#Time&#34;&gt;&lt;code&gt;Time&lt;/code&gt;&lt;/a&gt; has an associated &lt;a href=&#34;https://golang.org/pkg/time/#Location&#34;&gt;&lt;code&gt;Location&lt;/code&gt;&lt;/a&gt;, which is used for display purposes.&lt;/p&gt;&#xA;&lt;p&gt;The method &lt;a href=&#34;https://golang.org/pkg/time/#Time.In&#34;&gt;&lt;code&gt;In&lt;/code&gt;&lt;/a&gt; returns a time with a specific location. Changing the location in this way changes only the presentation; it does not change the instant in time.&lt;/p&gt;&#xA;&lt;p&gt;Here is a convenience function that changes the location associated with a time.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// TimeIn returns the time in UTC if the name is &#34;&#34; or &#34;UTC&#34;.&#xA;// It returns the local time if the name is &#34;Local&#34;.&#xA;// Otherwise, the name is taken to be a location name in&#xA;// the IANA Time Zone database, such as &#34;Africa/Lagos&#34;.&#xA;func TimeIn(t time.Time, name string) (time.Time, error) {&#xA;&#x9;loc, err := time.LoadLocation(name)&#xA;&#x9;if err == nil {&#xA;&#x9;&#x9;t = t.In(loc)&#xA;&#x9;}&#xA;&#x9;return t, err&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In use:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Timer and Ticker: events in the future</title>
      <link>https://yourbasic.org/golang/time-reset-wait-stop-timeout-cancel-interval/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/time-reset-wait-stop-timeout-cancel-interval/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Timers and Tickers let you execute code in the future, once or repeatedly.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/en/time-scholarship-2160154/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/timekeepers.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#timeout-timer&#34;&gt;Timeout (Timer)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#repeat-ticker&#34;&gt;Repeat (Ticker)&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#wait-act-and-cancel&#34;&gt;Wait, act and cancel&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;timeout-timer&#34;&gt;Timeout (Timer)&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://golang.org/pkg/time/#After&#34;&gt;&lt;code&gt;time.After&lt;/code&gt;&lt;/a&gt;&#xA;waits for a specified duration and then sends the current time&#xA;on the returned channel:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;select {&#xA;case news := &amp;lt;-AFP:&#xA;&#x9;fmt.Println(news)&#xA;case &amp;lt;-time.After(time.Hour):&#xA;&#x9;fmt.Println(&amp;#34;No news in an hour.&amp;#34;)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The underlying &lt;a href=&#34;https://golang.org/pkg/time/#Timer&#34;&gt;&lt;code&gt;time.Timer&lt;/code&gt;&lt;/a&gt;&#xA;will not be recovered by the garbage collector until the timer fires.&#xA;If this is a concern, use &lt;a href=&#34;https://golang.org/pkg/time/#NewTimer&#34;&gt;&lt;code&gt;time.NewTimer&lt;/code&gt;&lt;/a&gt;&#xA;instead and call its &lt;a href=&#34;https://golang.org/pkg/time/#Timer.Stop&#34;&gt;&lt;code&gt;Stop&lt;/code&gt;&lt;/a&gt; method&#xA;when the timer is no longer needed:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Top programming languages in use 2000-2020 [informal study]</title>
      <link>https://yourbasic.org/top-programming-languages/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/top-programming-languages/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/sv/photos/skyskrapor-sky-stadsbilden-h%C3%B6ga-1081737/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/res/skyscrapers.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#summary&#34;&gt;Summary&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#language-trends-2000-2020&#34;&gt;Language trends 2000–2020&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#top-languages-2020&#34;&gt;Top languages 2020&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;&#xA;&lt;p&gt;This informal long-time study gives a broad estimate of what&#xA;programming languages are &lt;strong&gt;used commercially&lt;/strong&gt; in the US.&#xA;For the last &lt;strong&gt;20 years&lt;/strong&gt;, I&amp;rsquo;ve done a job search at&#xA;&lt;a href=&#34;https://www.dice.com&#34;&gt;www.dice.com&lt;/a&gt;&#xA;for some of the most popular languages.&lt;/p&gt;&#xA;&lt;p&gt;Main takeaways:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Some much-talked-about languages find only little use in industry.&lt;/li&gt;&#xA;&lt;li&gt;Java, JavaScript, and Python have taken a large and stable market share during the last 20 years.&lt;/li&gt;&#xA;&lt;li&gt;C/C++ has slipped to fourth position.&lt;/li&gt;&#xA;&lt;li&gt;A huge number of programming jobs disappeared from the US job market after the &lt;a href=&#34;https://en.wikipedia.org/wiki/Dot-com_bubble&#34;&gt;dot-com crash&lt;/a&gt;&#xA;in 2000.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;language-trends-20002020&#34;&gt;Language trends 2000–2020&lt;/h2&gt;&#xA;&lt;p&gt;Number of hits (x1,000) on &lt;a href=&#34;https://www.dice.com&#34;&gt;Dice&lt;/a&gt;, tech jobs search engine,&#xA;&lt;span style=&#34;color: green&#34;&gt;March 2020&lt;/span&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Treaps: Randomized search trees</title>
      <link>https://yourbasic.org/algorithms/treap/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/treap/</guid>
      <description>&lt;!-- CC0: https://pixabay.com/en/tree-trunk-abstract-brown-food-157673/ (missing) --&gt;&#xA;&lt;div&gt;&lt;img class=&#34;extra-content&#34; src=&#34;https://yourbasic.org/algorithms/search-tree.png&#34; alt=&#34;symbolic search tree&#34; style=&#34;float:right;margin:10px 0 10px 20px;&#34;&gt;&lt;/div&gt;&#xA;&lt;p class=&#34;lead&#34;&gt;A treap stores items in sorted order and offers effi&amp;shy;cient lookup, addi&amp;shy;tion and remo&amp;shy;val of items.&lt;/p&gt;&#xA;&lt;p&gt;If you could use only one data structure, which one would you choose?&#xA;A hash table? While it supports the basic lookup, addition and removal operations,&#xA;it doesn’t keep the elements sorted.&#xA;Therefore it can’t efficiently perform some common tasks,&#xA;such as finding the minimum element or producing an ordered list of all elements.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Type alias explained</title>
      <link>https://yourbasic.org/golang/type-alias/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/type-alias/</guid>
      <description>&lt;!-- CC BY-SA 3.0: https://it.wikipedia.org/wiki/File:Disegno_personaggio_in_incognito.png --&gt;&#xA;&lt;div class=&#34;extra-content&#34; style=&#34;float:right; margin: -60px 0 0 20px;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/persona-incognito.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;An &lt;strong&gt;alias declaration&lt;/strong&gt; has the form&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;type T1 = T2&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;as opposed to a standard &lt;strong&gt;type definition&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type T1 T2&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;An alias declaration doesn&amp;rsquo;t create a new distinct type different&#xA;from the type it&amp;rsquo;s created from.&#xA;It just introduces an alias name &lt;code&gt;T1&lt;/code&gt;, an alternate spelling,&#xA;for the type denoted by &lt;code&gt;T2&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Type aliases are not meant for everyday use.&#xA;They were introduced to support gradual code repair while moving&#xA;a type between packages during large-scale refactoring.&#xA;&lt;a href=&#34;https://talks.golang.org/2016/refactor.article&#34;&gt;Codebase Refactoring (with help from Go)&lt;/a&gt;&#xA;covers this in detail.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Type assertions and type switches</title>
      <link>https://yourbasic.org/golang/type-assertion-switch/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/type-assertion-switch/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;A type assertion provides access to an interface’s concrete value.&lt;/p&gt;&#xA;&lt;!-- CC0: https://www.maxpixel.net/Gesture-Thumbs-Up-Feedback-Faust-Hand-Wrist-3050586 --&gt;&#xA;&lt;div style=&#34;float:right&#34; class=&#34;extra-content&#34;&gt;&lt;img width=&#34;320px&#34; src=&#34;https://yourbasic.org/golang/thumbs-up.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#type-assertions&#34;&gt;Type assertions&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#type-switches&#34;&gt;Type switches&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;type-assertions&#34;&gt;Type assertions&lt;/h2&gt;&#xA;&lt;p&gt;A &lt;strong&gt;type assertion&lt;/strong&gt; doesn’t really convert an &lt;a href=&#34;https://yourbasic.org/golang/interfaces-explained/&#34;&gt;interface&lt;/a&gt; to another data type,&#xA;but it provides access to an interface’s concrete value, which is typically what you want.&lt;/p&gt;&#xA;&lt;p&gt;The type assertion &lt;code&gt;x.(T)&lt;/code&gt; asserts that the concrete value stored in &lt;code&gt;x&lt;/code&gt;&#xA;is of type &lt;code&gt;T&lt;/code&gt;, and that &lt;code&gt;x&lt;/code&gt; is not nil.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;If &lt;code&gt;T&lt;/code&gt; is not an interface, it asserts that the dynamic type of &lt;code&gt;x&lt;/code&gt; is identical to &lt;code&gt;T&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If &lt;code&gt;T&lt;/code&gt; is an interface, it asserts that the dynamic type of &lt;code&gt;x&lt;/code&gt; implements &lt;code&gt;T&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;var x interface{} = &#34;foo&#34;&#xA;&#xA;var s string = x.(string)&#xA;fmt.Println(s)     &lt;span class=&#34;comment&#34;&gt;// &#34;foo&#34;&lt;/span&gt;&#xA;&#xA;s, ok := x.(string)&#xA;fmt.Println(s, ok) &lt;span class=&#34;comment&#34;&gt;// &#34;foo true&#34;&lt;/span&gt;&#xA;&#xA;n, ok := x.(int)&#xA;fmt.Println(n, ok) &lt;span class=&#34;comment&#34;&gt;// &#34;0 false&#34;&lt;/span&gt;&#xA;&#xA;n = x.(int)        &lt;span class=&#34;comment&#34;&gt;// ILLEGAL&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;panic: interface conversion: interface {} is string, not int&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;type-switches&#34;&gt;Type switches&lt;/h2&gt;&#xA;&lt;p&gt;A &lt;strong&gt;type switch&lt;/strong&gt; performs several type assertions in series and&#xA;runs the first case with a matching type.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Type, value and equality of interfaces</title>
      <link>https://yourbasic.org/golang/interfaces-explained/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/interfaces-explained/</guid>
      <description>&lt;!-- CC0: http://maxpixel.freegreatpicture.com/Hand-In-Hand-Hands-Connection-Love-Heart-Anchor-1100886 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/connection.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#interface-type&#34;&gt;Interface type&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#structural-typing&#34;&gt;Structural typing&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#the-empty-interface&#34;&gt;The empty interface&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#interface-values&#34;&gt;Interface values&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#equality&#34;&gt;Equality&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;interface-type&#34;&gt;Interface type&lt;/h2&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;An interface type consists of a set of method signatures.&#xA;A variable of interface type can hold any value that implements these methods.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;p&gt;In this example both &lt;code&gt;Temp&lt;/code&gt; and &lt;code&gt;*Point&lt;/code&gt; implement the &lt;code&gt;MyStringer&lt;/code&gt; interface.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type MyStringer interface {&#xA;&#x9;String() string&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type Temp int&#xA;&#xA;func (t Temp) String() string {&#xA;&#x9;return strconv.Itoa(int(t)) + &amp;#34; °C&amp;#34;&#xA;}&#xA;&#xA;type Point struct {&#xA;&#x9;x, y int&#xA;}&#xA;&#xA;func (p *Point) String() string {&#xA;&#x9;return fmt.Sprintf(&amp;#34;(%d,%d)&amp;#34;, p.x, p.y)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Actually, &lt;code&gt;*Temp&lt;/code&gt; also implements &lt;code&gt;MyStringer&lt;/code&gt;, since the method set of&#xA;a pointer type &lt;code&gt;*T&lt;/code&gt; is the set of all methods with receiver &lt;code&gt;*T&lt;/code&gt; or &lt;code&gt;T&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unexpected &#43;&#43;, expecting expression</title>
      <link>https://yourbasic.org/golang/gotcha-increment-decrement-statement/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-increment-decrement-statement/</guid>
      <description>&lt;!-- CC BY-NC-ND 2.0: https://www.flickr.com/photos/ruminatrix/3052493260/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/syntax-terror-640.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t these lines compile?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;i := 0&#xA;fmt.Println(++i)&#xA;fmt.Println(i++)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;main.go:9:14: syntax error: unexpected ++, expecting expression&#xA;main.go:10:15: syntax error: unexpected ++, expecting comma or )&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;In Go increment and decrement operations can’t be used as expressions, only as &lt;strong&gt;statements&lt;/strong&gt;.&#xA;Also, only the &lt;strong&gt;postfix notation&lt;/strong&gt; is&amp;nbsp;allowed.&lt;/p&gt;&#xA;&lt;p&gt;The above snippet needs to be written as:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;i := 0&#xA;i++&#xA;fmt.Println(i)&#xA;fmt.Println(i)&#xA;i++&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote&gt;&#xA;  &lt;p&gt;Without pointer arithmetic, the convenience value of pre- and postfix increment operators drops. By removing them from the expression hierarchy altogether, expression syntax is simplified and the messy issues around order of evaluation of &lt;code&gt;++&lt;/code&gt; and &lt;code&gt;--&lt;/code&gt; (consider &lt;code&gt;f(i++)&lt;/code&gt; and &lt;code&gt;p[i] = q[++i]&lt;/code&gt;) are eliminated as well. The simplification is&amp;nbsp;significant.&#xA;&lt;a class=&#34;quote-source&#34; href=&#34;https://golang.org/doc/faq#inc_dec&#34;&gt;Go FAQ: Why are ++ and – statements and not expressions?&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unexpected newline</title>
      <link>https://yourbasic.org/golang/gotcha-missing-comma-slice-array-map-literal/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-missing-comma-slice-array-map-literal/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/sfllaw/3186749460 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/surprise.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why doesn&amp;rsquo;t this program compile?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;fruit := []string{&#xA;&#x9;&#x9;&#34;apple&#34;,&#xA;&#x9;&#x9;&#34;banana&#34;,&#xA;&#x9;&#x9;&#34;cherry&#34;&#xA;&#x9;}&#xA;&#x9;fmt.Println(fruit)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:5:11: syntax error: unexpected newline, expecting comma or }&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;In a multi-line slice, array or map literal, every line &lt;b&gt;must end with a comma&lt;/b&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;skiphl&#34;&gt;func main() {&#xA;&#x9;fruit := []string{&#xA;&#x9;&#x9;&#34;apple&#34;,&#xA;&#x9;&#x9;&#34;banana&#34;,&#xA;&#x9;&#x9;&#34;cherry&#34;&lt;b&gt;,&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// comma added&lt;/span&gt;&#xA;&#x9;}&#xA;&#x9;fmt.Println(fruit) &lt;span class=&#34;comment&#34;&gt;// &#34;[apple banana cherry]&#34;&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This behavior is a consequence of the Go &lt;a href=&#34;https://golang.org/ref/spec#Semicolons&#34;&gt;semicolon insertion rules&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unexpected values in range loop</title>
      <link>https://yourbasic.org/golang/gotcha-unexpected-values-range/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-unexpected-values-range/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Man-People-Human-Age-Senior-New-Media-Surprise-1332348 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/surprised-man.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does this code&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;primes := []int{2, 3, 5, 7}&#xA;for p := range primes {&#xA;&#x9;fmt.Println(p)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;print&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;0&#xA;1&#xA;2&#xA;3&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;For arrays and slices, the range loop generates &lt;strong&gt;two&amp;nbsp;values&lt;/strong&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt; first the index,&lt;/li&gt;&#xA;&lt;li&gt; then the data at this position.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you omit the second value, you get only the indices.&lt;/p&gt;&#xA;&lt;p&gt;To print the data, use the second value instead:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code class=&#34;language-go&#34;&gt;primes := []int{2, 3, 5, 7}&#xA;for &lt;span class=&#34;highlight&#34;&gt;_, &lt;/span&gt;p := range primes {&#xA;&#x9;fmt.Println(p)&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In this case, the blank identifier (underscore) is used for the return value you&#39;re not interested&amp;nbsp;in.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unit cost vs. bit cost in time complexity</title>
      <link>https://yourbasic.org/algorithms/unit-cost-vs-bit-cost/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/unit-cost-vs-bit-cost/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/illuminated_photography/3153988939 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/unit-cost-multiplication.jpg&#34; alt=&#34;Unit-cost multiplication devise.&#34;&gt;&lt;/div&gt;&#xA;&lt;div&gt;&lt;i&gt;Unit-cost multiplication&lt;/i&gt;&lt;/div&gt;&#xA;&lt;p&gt;Unit cost and bit cost are two different cost functions used to compute&#xA;space and time &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-explained/&#34;&gt;complexity&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Unit cost&lt;/strong&gt; is used in a simplified model where a number,&#xA;of any size, fits within a memory cell, and where standard arithmetic operations&#xA;take constant time.&lt;/li&gt;&#xA;&lt;li&gt;With &lt;strong&gt;bit cost&lt;/strong&gt; we take into account that computations with bigger numbers&#xA;can be more expensive.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Unit cost often works well in practice as modern processors can perform&#xA;arithmetics on 64-bit integer and floating point numbers&#xA;in &lt;a href=&#34;https://yourbasic.org/algorithms/big-o-notation-explained/#constant-time&#34;&gt;constant time&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Untyped numeric constants with no limits</title>
      <link>https://yourbasic.org/golang/untyped-constants/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/untyped-constants/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/1161134 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/infinite-highway.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Constants may be &lt;strong&gt;typed&lt;/strong&gt; or &lt;strong&gt;untyped&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const a uint = 17&#xA;const b = 55&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;An untyped constant has &lt;strong&gt;no limits&lt;/strong&gt;. When it&amp;rsquo;s used in a context that requires a type, a type will be inferred and a limit applied.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const big = 10000000000  &lt;span class=&#34;comment&#34;&gt;// Ok, even though it&#39;s too big for an int.&lt;/span&gt;&#xA;const bigger = big * 100 &lt;span class=&#34;comment&#34;&gt;// Still ok.&lt;/span&gt;&#xA;var i int = big / 100    &lt;span class=&#34;comment&#34;&gt;// No problem: the new result fits in an int.&lt;/span&gt;&#xA;&#xA;&lt;span class=&#34;comment&#34;&gt;// Compile time error: &#34;constant 10000000000 overflows int&#34;&lt;/span&gt;&#xA;var j int = big&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The inferred type is determined by the syntax of the value:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unused local variables</title>
      <link>https://yourbasic.org/golang/unused-local-variables/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/unused-local-variables/</guid>
      <description>&lt;!-- CC0: https://pxhere.com/en/photo/1068739 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/red-pencil-on-red-background.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;As you may have noticed, programs with unused local variables do not compile.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func main() {&#xA;&#x9;var n int &lt;span class=&#34;comment&#34;&gt;// &#34;n declared and not used&#34;&lt;/span&gt;&#xA;&#x9;n = 5     &lt;span class=&#34;comment&#34;&gt;// this doesn&#39;t help&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:2:6: n declared and not used&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is a deliberate feature of the Go language.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The presence of an unused variable may indicate a bug [&amp;hellip;]&#xA;Go refuses to compile programs with unused variables or imports,&#xA;trading short-term convenience for long-term build speed and program clarity.&#xA;&lt;a class=&#34;quote-source&#34; href=&#34;https://golang.org/doc/faq#unused_variables_and_imports&#34;&gt;Go FAQ: Can I stop these complaints about my unused variable/import?&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Unused package imports</title>
      <link>https://yourbasic.org/golang/unused-imports/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/unused-imports/</guid>
      <description>&lt;!-- CC0: https://pixnio.com/miscellaneous/red-pencil-drawing-creativity-wooden --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/red-cross-wrong.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;As you may have noticed, programs with unused &lt;a href=&#34;https://yourbasic.org/golang/packages-explained/&#34;&gt;package&lt;/a&gt; imports do not compile.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;package main&#xA;&#xA;import (&#xA;&#x9;&#34;fmt&#34;&#xA;&#x9;&#34;log&#34; &lt;span class=&#34;comment&#34;&gt;// &#34;imported and not used: log&#34;&lt;/span&gt;&#xA;)&#xA;&#xA;func main() {&#xA;&#x9;fmt.Println(&#34;Hello&#34;)&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;../main.go:5:2: imported and not used: &amp;#34;log&amp;#34;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is a deliberate feature of the Go language.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The presence of an unused variable may indicate a bug [&amp;hellip;]&#xA;Go refuses to compile programs with unused variables or imports,&#xA;trading short-term convenience for long-term build speed and program clarity.&#xA;&lt;a class=&#34;quote-source&#34; href=&#34;https://golang.org/doc/faq#unused_variables_and_imports&#34;&gt;Go FAQ: Can I stop these complaints about my unused variable/import?&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>User-friendly access to crypto/rand</title>
      <link>https://yourbasic.org/golang/crypto-rand-int/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/crypto-rand-int/</guid>
      <description>&lt;!-- CC BY-NC-SA 2.0: http://www.flickr.com/photos/stianeikeland/3696386615/ --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/res/programmer.jpg&#34; alt=&#34;Masked programmer&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Go has two packages for random numbers:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/math/rand/&#34;&gt;&lt;code&gt;math/rand&lt;/code&gt;&lt;/a&gt; implements a large selection of pseudo-random number generators.&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/crypto/rand/&#34;&gt;&lt;code&gt;crypto/rand&lt;/code&gt;&lt;/a&gt; implements a cryptographically secure pseudo-random number generator with a limited interface.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The two packages can be combined by calling &lt;a href=&#34;https://golang.org/pkg/math/rand/#New&#34;&gt;&lt;code&gt;rand.New&lt;/code&gt;&lt;/a&gt;&#xA;in package &lt;code&gt;math/rand&lt;/code&gt; with a source that gets its data from &lt;code&gt;crypto/rand&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import (&#xA;&#x9;crand &#34;crypto/rand&#34;&#xA;&#x9;rand &#34;math/rand&#34;&#xA;&#xA;&#x9;&#34;encoding/binary&#34;&#xA;&#x9;&#34;fmt&#34;&#xA;&#x9;&#34;log&#34;&#xA;)&#xA;&#xA;func main() {&#xA;&#x9;var src cryptoSource&#xA;&#x9;rnd := rand.New(src)&#xA;&#x9;fmt.Println(rnd.Intn(1000)) &lt;span class=&#34;comment&#34;&gt;// a truly random number 0 to 999&lt;/span&gt;&#xA;}&#xA;&#xA;type cryptoSource struct{}&#xA;&#xA;func (s cryptoSource) Seed(seed int64) {}&#xA;&#xA;func (s cryptoSource) Int63() int64 {&#xA;&#x9;return int64(s.Uint64() &amp; ^uint64(1&lt;&lt;63))&#xA;}&#xA;&#xA;func (s cryptoSource) Uint64() (v uint64) {&#xA;&#x9;err := binary.Read(crand.Reader, binary.BigEndian, &amp;v)&#xA;&#x9;if err != nil {&#xA;&#x9;&#x9;log.Fatal(err)&#xA;&#x9;}&#xA;&#x9;return v&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;blockquote class=&#34;warning&#34;&gt;&#xA;&lt;b&gt;Warning:&lt;/b&gt; The &lt;code&gt;crand.Reader&lt;/code&gt; returns an error if the underlying system call fails.&#xA;For instance if it can&#39;t read &lt;code&gt;/dev/urandom&lt;/code&gt; on a Unix system,&#xA;or if &lt;a href=&#34;https://msdn.microsoft.com/en-us/library/windows/desktop/aa379886(v=vs.85).aspx&#34;&gt;&lt;code&gt;CryptAcquireContext&lt;/code&gt;&lt;/a&gt;&#xA;fails on a Windows system.&#xA;&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>Variadic functions (...T)</title>
      <link>https://yourbasic.org/golang/variadic-function/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/variadic-function/</guid>
      <description>&lt;!-- CC0: https://commons.wikimedia.org/wiki/File:Adjustable_spanner_20101109.jpg --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/golang/adjustable-spanner.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#basics&#34;&gt;Basics&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#pass-slice-elements-to-a-variadic-function&#34;&gt;Pass slice elements to a variadic function&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#append-is-variadic&#34;&gt;Append is variadic&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;basics&#34;&gt;Basics&lt;/h2&gt;&#xA;&lt;p&gt;If the &lt;strong&gt;last parameter&lt;/strong&gt; of a function has type &lt;code&gt;...T&lt;/code&gt;&#xA;it can be called with &lt;strong&gt;any number&lt;/strong&gt; of trailing arguments of type &lt;code&gt;T&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Sum(&lt;b&gt;nums ...int&lt;/b&gt;) int {&#xA;&#x9;res := 0&#xA;&#x9;for _, n := range nums {&#xA;&#x9;&#x9;res += n&#xA;&#x9;}&#xA;&#x9;return res&#xA;}&#xA;&#xA;func main()&#xA;&#x9;fmt.Println(&lt;b&gt;Sum()&lt;/b&gt;)        &lt;span class=&#34;comment&#34;&gt;// 0&lt;/span&gt;&#xA;&#x9;fmt.Println(&lt;b&gt;Sum(1, 2, 3)&lt;/b&gt;) &lt;span class=&#34;comment&#34;&gt;// 6&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The actual type of &lt;code&gt;...T&lt;/code&gt; inside the function is &lt;code&gt;[]T&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Waiting for goroutines</title>
      <link>https://yourbasic.org/golang/wait-for-goroutines-waitgroup/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/wait-for-goroutines-waitgroup/</guid>
      <description>&lt;!-- CC BY 2.0: https://www.flickr.com/photos/56218409@N03/44497152140--&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/waiting-dog.jpg&#34;/&gt;&lt;/div&gt;&#xA;&lt;p&gt;A &lt;a href=&#34;https://golang.org/pkg/sync/&#34;&gt;&lt;code&gt;sync.WaitGroup&lt;/code&gt;&lt;/a&gt; waits for a group of goroutines to finish.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var wg sync.WaitGroup&#xA;wg.Add(2)&#xA;go func() {&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// Do work.&lt;/span&gt;&#xA;&#x9;wg.Done()&#xA;}()&#xA;go func() {&#xA;&#x9;&lt;span class=&#34;comment&#34;&gt;// Do work.&lt;/span&gt;&#xA;&#x9;wg.Done()&#xA;}()&#xA;wg.Wait()&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;First the main goroutine calls &lt;a href=&#34;https://golang.org/pkg/sync/#WaitGroup.Add&#34;&gt;&lt;code&gt;Add&lt;/code&gt;&lt;/a&gt;&#xA;to set the number of goroutines to wait for.&lt;/li&gt;&#xA;&lt;li&gt;Then two new goroutines run and call&#xA;&lt;a href=&#34;https://golang.org/pkg/sync/#WaitGroup.Done&#34;&gt;&lt;code&gt;Done&lt;/code&gt;&lt;/a&gt; when finished.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;em&gt;At the same time&lt;/em&gt;, &lt;a href=&#34;https://golang.org/pkg/sync/#WaitGroup.Wait&#34;&gt;&lt;code&gt;Wait&lt;/code&gt;&lt;/a&gt;&#xA;is used to block until these two goroutines have finished.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What happened to ABBA?</title>
      <link>https://yourbasic.org/golang/gotcha-trim-string/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-trim-string/</guid>
      <description>&lt;!-- CC BY 3.0: https://en.wikipedia.org/wiki/File:ABBA_Edmonton_1979_001.jpg --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/abba.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;What&amp;rsquo;s up with &lt;a href=&#34;https://golang.org/pkg/strings/#TrimRight&#34;&gt;strings.TrimRight&lt;/a&gt;?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Println(strings.TrimRight(&#34;ABBA&#34;, &#34;BA&#34;)) &lt;span class=&#34;comment&#34;&gt;// Output: &#34;&#34;&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;code&gt;Trim&lt;/code&gt;, &lt;code&gt;TrimLeft&lt;/code&gt; and &lt;code&gt;TrimRight&lt;/code&gt; functions strip all Unicode code points contained in a &lt;b&gt;cutset&lt;/b&gt;.&#xA;In this case, all trailing A:s and B:s are stripped from the string, leaving the empty string.&lt;/p&gt;&#xA;&lt;p&gt;To strip a trailing &lt;b&gt;string&lt;/b&gt;, use&#xA;&lt;a href=&#34;https://golang.org/pkg/strings/#TrimSuffix&#34;&gt;&lt;code&gt;strings.TrimSuffix&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;fmt.Println(strings.&lt;b&gt;TrimSuffix&lt;/b&gt;(&#34;ABBA&#34;, &#34;BA&#34;)) &lt;span class=&#34;comment&#34;&gt;// Output: &#34;AB&#34;&lt;/span&gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/string-functions-reference-cheat-sheet/&#34;&gt;String functions cheat sheet&lt;/a&gt; for more about strings in&amp;nbsp;Go.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What’s a seed in a random number generator?</title>
      <link>https://yourbasic.org/algorithms/random-number-generator-seed/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/random-number-generator-seed/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;In reality pseudo&amp;shy;random numbers aren&#39;t random at all.&#xA;They are computed using a fixed determi&amp;shy;nistic algorithm.&lt;/p&gt;&#xA;&lt;!-- CC BY-NC-SA 2.0: https://www.flickr.com/photos/rosswebsdale/2510946638/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/dominoes.jpg&#34; alt=&#34;dominoes falling over&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;The &lt;strong&gt;seed&lt;/strong&gt; is a starting point for a sequence of pseudorandom numbers.&#xA;If you start from the same seed, you get the very same sequence.&#xA;This can be quite useful for debugging.&lt;/p&gt;&#xA;&lt;p&gt;If you want a different sequence of numbers each time,&#xA;you can use the &lt;strong&gt;current time&lt;/strong&gt; as a seed.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Whatever remains</title>
      <link>https://yourbasic.org/golang/gotcha-remainder-modulo-operator/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-remainder-modulo-operator/</guid>
      <description>&lt;!-- CC0: https://pixnio.com/miscellaneous/red-pencil-drawing-creativity-wooden --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/red-cross-wrong.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why isn&amp;rsquo;t -1 odd?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;func Odd(n int) bool {&#xA;&#x9;return n%2 == 1&#xA;}&#xA;&#xA;func main() {&#xA;&#x9;fmt.Println(Odd(-1)) &lt;span class=&#34;comment&#34;&gt;// &lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The remainder operator can give negative answers if the dividend is negative:&#xA;if &lt;code&gt;n&lt;/code&gt; is an odd negative number, &lt;code&gt;n&amp;nbsp;%&amp;nbsp;2&lt;/code&gt; equals&amp;nbsp;&lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The  quotient &lt;code&gt;q = x&amp;nbsp;/&amp;nbsp;y&lt;/code&gt; and remainder &lt;code&gt;r = x&amp;nbsp;%&amp;nbsp;y&lt;/code&gt;&#xA;satisfy the relationships&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;x = q*y + r  and  |r| &amp;lt; |y|&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;where &lt;code&gt;x / y&lt;/code&gt; is truncated towards zero.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Where is my copy?</title>
      <link>https://yourbasic.org/golang/gotcha-copy-missing/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-copy-missing/</guid>
      <description>&lt;!-- CC0: https://www.maxpixel.net/Drilled-Down-Paper-Text-Box-Rip-Torn-Copy-Space-3792307 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/hole-in-paper.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;Why does the copy disappear?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var src, dst []int&#xA;src = []int{1, 2, 3}&#xA;copy(dst, src) &lt;span class=&#34;comment&#34;&gt;// Copy elements to dst from src.&lt;/span&gt;&#xA;fmt.Println(&#34;dst:&#34;, dst)&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;dst: []&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;The number of elements copied by the &lt;code&gt;copy&lt;/code&gt; function&#xA;is the minimum of &lt;code&gt;len(dst)&lt;/code&gt; and &lt;code&gt;len(src)&lt;/code&gt;.&#xA;To make a full copy, you must allocate a big enough destination slice.&#xA;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;var src, dst []int&#xA;src = []int{1, 2, 3}&#xA;&lt;b&gt;dst = make([]int, len(src))&lt;/b&gt;&#xA;n := copy(dst, src)&#xA;fmt.Println(&#34;dst:&#34;, dst, &#34;(copied&#34;, n, &#34;numbers)&#34;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;pre&gt;dst: [1 2 3] (copied 3 numbers)&lt;/pre&gt;&#xA;&lt;p&gt;The return value of the &lt;code&gt;copy&lt;/code&gt; function is the number of elements copied.&#xA;See &lt;a href=&#34;https://yourbasic.org/golang/copy-explained/&#34;&gt;Copy function&lt;/a&gt; for more about&#xA;the built-in &lt;code&gt;copy&lt;/code&gt; function in&amp;nbsp;Go.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Where is the ternary conditional operator?</title>
      <link>https://yourbasic.org/golang/ternary-if-else-statement/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/ternary-if-else-statement/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/if-else-statement/&#34;&gt;4 basic if-else statement patterns&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why doesn’t append work every time? [scary bug]</title>
      <link>https://yourbasic.org/golang/gotcha-append/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/gotcha-append/</guid>
      <description>&lt;!-- CC BY-SA 2.0: https://www.flickr.com/photos/petebackwards/452491222 --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/scary-bug.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;What&amp;rsquo;s up with the append function?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []byte(&#34;ba&#34;)&#xA;&#xA;a1 := append(a, &#39;d&#39;)&#xA;a2 := append(a, &#39;g&#39;)&#xA;&#xA;fmt.Println(string(a1)) &lt;span class=&#34;comment&#34;&gt;// bag&lt;/span&gt;&#xA;fmt.Println(string(a2)) &lt;span class=&#34;comment&#34;&gt;// bag&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h2 id=&#34;answer&#34;&gt;Answer&lt;/h2&gt;&#xA;&lt;p&gt;If there is room for more elements, &lt;code&gt;append&lt;/code&gt; reuses the underlying array.&#xA;Let&#39;s take a&amp;nbsp;look:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;a := []byte(&#34;ba&#34;)&#xA;&lt;b&gt;fmt.Println(len(a), cap(a))&lt;/b&gt; &lt;span class=&#34;comment&#34;&gt;// 2 32&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This means that the slices &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;a1&lt;/code&gt; and &lt;code&gt;a2&lt;/code&gt;&#xA;will refer to the same underlying array in our example.&lt;/p&gt;&#xA;&lt;p&gt;To avoid this, we need to use two separate byte&amp;nbsp;arrays.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why Go? – Key advantages you may have overlooked</title>
      <link>https://yourbasic.org/golang/advantages-over-java-python/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/advantages-over-java-python/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;Go makes it easier (than Java or Python) to write correct, clear and efficient code.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/vectors/happiness-speed-horse-mare-animal-2156794/ --&gt;&#xA;&lt;div&gt;&lt;img style=&#34;border:1px solid gray&#34; src=&#34;https://yourbasic.org/golang/unicorn.png&#34; alt=&#34;Unicorn racing towards the Rainbow&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#minimalism&#34;&gt;Minimalism&lt;/a&gt;&#xA;    &lt;ul style=&#34;list-style: none; font-weight: normal; margin-top: 0.2em;&#34;&gt;&#xA;      &lt;li&gt;&lt;a href=&#34;#features-for-the-future&#34;&gt;Features for the future&lt;/a&gt;&lt;/li&gt;&#xA;    &lt;/ul&gt;&#xA;  &lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#code-transparency&#34;&gt;Code transparency&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#compatibility&#34;&gt;Compatibility&lt;/a&gt;&lt;/li&gt;&#xA;  &lt;li&gt;&lt;a href=&#34;#performance&#34;&gt;Performance&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Choosing a programming language isn&amp;rsquo;t easy.&#xA;The separate features of a language may look great at first,&#xA;but it takes &lt;em&gt;time&lt;/em&gt; and &lt;em&gt;experience&lt;/em&gt; to spot the drawbacks.&lt;/p&gt;&#xA;&lt;p&gt;As a CS professor and longtime Go and Java developer, I&amp;rsquo;d like to&#xA;share some of my thoughts and explain why I prefer &lt;strong&gt;&lt;a href=&#34;https://golang.org/&#34;&gt;Go&lt;/a&gt;&lt;/strong&gt;&#xA;to &lt;strong&gt;&lt;a href=&#34;https://www.java.com/&#34;&gt;Java&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href=&#34;https://www.python.org/&#34;&gt;Python&lt;/a&gt;&lt;/strong&gt; –&#xA;Go makes it much easier for me to write good code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Write log to file (or /dev/null)</title>
      <link>https://yourbasic.org/golang/log-to-file/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/log-to-file/</guid>
      <description>&lt;!-- CC0: https://commons.wikimedia.org/wiki/File:Transcription_using_cylinder_phonograph.png --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/transcription-using-cylinder-phonograph.png&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;This code appends a log message to the file &lt;code&gt;text.log&lt;/code&gt;.&#xA;It creates the file if it doesn&amp;rsquo;t already exist.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;f, err := os.OpenFile(&amp;#34;text.log&amp;#34;,&#xA;&#x9;os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)&#xA;if err != nil {&#xA;&#x9;log.Println(err)&#xA;}&#xA;defer f.Close()&#xA;&#xA;logger := log.New(f, &amp;#34;prefix&amp;#34;, log.LstdFlags)&#xA;logger.Println(&amp;#34;text to append&amp;#34;)&#xA;logger.Println(&amp;#34;more text to append&amp;#34;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Contents of &lt;code&gt;text.log&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;prefix: 2017/10/20 07:52:58 text to append&#xA;prefix: 2017/10/20 07:52:58 more text to append&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://golang.org/pkg/log/#New&#34;&gt;&lt;code&gt;log.New&lt;/code&gt;&lt;/a&gt; creates a new&#xA;&lt;a href=&#34;https://golang.org/pkg/log/#Logger&#34;&gt;&lt;code&gt;log.Logger&lt;/code&gt;&lt;/a&gt; that writes to &lt;code&gt;f&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;The prefix appears at the beginning of each generated log line.&lt;/li&gt;&#xA;&lt;li&gt;The &lt;a href=&#34;https://golang.org/pkg/log/#pkg-constants&#34;&gt;&lt;code&gt;flag&lt;/code&gt;&lt;/a&gt; argument defines which text&#xA;to prefix to each log entry.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;disable-logging&#34;&gt;Disable logging&lt;/h2&gt;&#xA;&lt;!-- CC0: https://www.publicdomainpictures.net/en/view-image.php?image=212480&amp;picture=blank-notebook --&gt;&#xA;&lt;div style=&#34;margin-top:1em;&#34;&gt;&lt;img src=&#34;https://yourbasic.org/golang/blank-notebook.jpg&#34;&gt;&lt;/div&gt;&#xA;&lt;p&gt;To turn off all output from a &lt;a href=&#34;https://golang.org/pkg/log/#Logger&#34;&gt;&lt;code&gt;log.Logger&lt;/code&gt;&lt;/a&gt;,&#xA;set the output destination to &lt;a href=&#34;https://golang.org/pkg/io/ioutil/#pkg-variables&#34;&gt;&lt;code&gt;ioutil.Discard&lt;/code&gt;&lt;/a&gt;,&#xA;a writer on which all calls succeed without doing anything.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Your basic int: a most powerful data type</title>
      <link>https://yourbasic.org/algorithms/your-basic-int/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/algorithms/your-basic-int/</guid>
      <description>&lt;p class=&#34;lead&#34;&gt;The int data type is generic, effective, simple and efficient.&lt;/p&gt;&#xA;&lt;!-- CC0: https://pixabay.com/en/counting-fingers-first-hand-one-154152/ --&gt;&#xA;&lt;div&gt;&lt;img src=&#34;https://yourbasic.org/algorithms/counting.png&#34;&gt;&lt;/div&gt;&#xA;&lt;ul class=&#34;toc&#34;&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#generic-graph-data&#34;&gt;Generic graph data&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#effective-searching-and-sorting&#34;&gt;Effective searching and sorting&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#simple-sets&#34;&gt;Simple sets&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#efficient-filtering&#34;&gt;Efficient filtering&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;Every kid can spot an integer number,&#xA;and every programmer is familiar with the &lt;code&gt;int&lt;/code&gt; data type.&#xA;Still we frequently forget how powerful an integer can be.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Generic&lt;/strong&gt;&lt;br&gt;&#xA;An &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;[]int&lt;/code&gt; is a bit pattern that can represent any digital data.&#xA;Furthermore, an &lt;code&gt;int&lt;/code&gt; can point into any type of &lt;a href=&#34;https://yourbasic.org/algorithms/time-complexity-arrays/&#34;&gt;array&lt;/a&gt;.&#xA;That&amp;rsquo;s as generic as it gets.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Effective&lt;/strong&gt;&lt;br&gt;&#xA;With an &lt;code&gt;int&lt;/code&gt; you have all of basic mathematics at your fingertips,&#xA;and boolean algebra, implemented with bit-level parallelism, to boot.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Simple&lt;/strong&gt;&lt;br&gt;&#xA;Not really, but we&amp;rsquo;ve used arithmetic since childhood so it feels that way.&#xA;Familiarity breeds both simplicity and contempt.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Efficient&lt;/strong&gt;&lt;br&gt;&#xA;An &lt;code&gt;int&lt;/code&gt; fits inside a register sitting on the main datapath of the CPU,&#xA;and an &lt;code&gt;[]int&lt;/code&gt; is the main focus of hardware memory optimization.&#xA;It doesn&amp;rsquo;t get much faster or more efficient than that.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;resources&#34;&gt;Resources&lt;/h3&gt;&#xA;&lt;p&gt;This text comes with four Go example libraries:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Zero knowledge (besserwisser alert)</title>
      <link>https://yourbasic.org/golang/zero-knowledge/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://yourbasic.org/golang/zero-knowledge/</guid>
      <description>&lt;p&gt;See &lt;a href=&#34;https://yourbasic.org/golang/gotcha-octal-decimal-hexadecimal-literal/&#34;&gt;Numbers that start with zero&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
