title: Labels - break vs continue vs goto
body: <p>I understand that:</p>
  
  <p><code>break</code> - stops further execution of a loop construct.</p>
  
  <p><code>continue</code> - skips the rest of the loop body and starts the next iteration.</p>
  
  <p>But how do these statements differ when used in combination with labels?</p>
  
  <p>In other words what is the difference between these three loops:</p>
  
  <pre><code>Loop:
      for i := 0; i &lt; 10; i++ {
          if i == 5 {
               break Loop
          }
          fmt.Println(i)
      }
  </code></pre>
  
  <hr>
  
  <p>Output:</p>
  
  <p>0 1 2 3 4</p>
  
  <hr>
  
  <pre><code>Loop:
      for i := 0; i &lt; 10; i++ {
          if i == 5 {
               continue Loop
          }
          fmt.Println(i)
      }
  </code></pre>
  
  <hr>
  
  <p>Output:</p>
  
  <p>0 1 2 3 4 6 7 8 9</p>
  
  <hr>
  
  <pre><code>Loop:
      for i := 0; i &lt; 10; i++ {
          if i == 5 {
               goto Loop
          }
          fmt.Println(i)
      }
  </code></pre>
  
  <hr>
  
  <p>Output:</p>
  
  <p>0 1 2 3 4 0 1 2 3 4 ... (infinite)</p>
  
  <hr>