Sobes.tech
Junior — Senior

How does a closure affect the value of a variable in a goroutine

livecode

Task condition

Determine which numbers the program will output during its execution.

func main() {
    for idx := 0; idx < 10; idx++ {
        go func() {
            fmt.Println(idx)
        }()
    }

    fmt.Println("done")
}