...

/

Puzzle 23 Explanation: Go Next

Puzzle 23 Explanation: Go Next

Understand how id works in Go.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Press + to interact
package main
import (
"fmt"
)
var (
id = nextID()
)
func nextID() int {
id++
return id
}
func main() {
fmt.Println(id)
}

Explanation

Building the code presents the following problem:

$ go build next_id.go
#
...