title: Infinite 'for' loop in Go
body: <p>I'm new to Go, but I would expect not to have issues with something as basic as this.</p>
  <pre><code>package main
  
  import &quot;fmt&quot;
  
  func main() {
      s := make([]int, 0)
      s = append(s, 1)
      for len(s) != 0 {
          j := len(s) - 1
          top, s := s[j], s[:j]
          fmt.Printf(&quot;top = %+v\n&quot;, top)
          fmt.Printf(&quot;s = %+v\n&quot;, s)
          fmt.Printf(&quot;len(s) = %+v\n&quot;, len(s))
      }
  }
  </code></pre>
  <p>This command doesn't exit. It just prints</p>
  <pre class="lang-none prettyprint-override"><code>len(s) = 0
  top = 1
  s = []
  len(s) = 0
  top = 1
  s = []
  len(s) = ^C
  </code></pre>
  <p>I find this stunning; what am I doing wrong? Syntactically, based on <a href="https://tour.golang.org/flowcontrol/3" rel="nofollow noreferrer">https://tour.golang.org/flowcontrol/3</a>, everything seems OK.</p>