title: Syntax Error: Non-declaration statement outside function body
body: <p>The function <code>makeEvenGenerator</code> is supposed to return a function that generates even numbers in a sequential manner:</p>
  
  <pre><code>package main 
  import "fmt"
  func makeEvenGenerator() func() uint {
      i := uint(0)
      return func() (ret uint) {
          ret = i
          i += 2
          return
      }
  }func main() {
      nextEven := makeEvenGenerator()
      fmt.Println(nextEven()) // 0
      fmt.Println(nextEven()) // 2
      fmt.Println(nextEven()) // 4
  }  
  </code></pre>
  
  <p>When I run it, I get the error <code>syntax error: unexpected func, expecting semicolon or newline</code> and <code>Non-declaration statement outside function body</code>.</p>
  
  <p>The code is taken verbatim from <em>An Introduction to Programming in Go</em> by Caleb Doxsey. I am not sure what the problem is. </p>