Skip to content

Instantly share code, notes, and snippets.

@horitaku1124
Last active September 17, 2015 04:26
Show Gist options
  • Save horitaku1124/f5c3213f03890c5f516b to your computer and use it in GitHub Desktop.
Save horitaku1124/f5c3213f03890c5f516b to your computer and use it in GitHub Desktop.
Testing goroutines on Go
package main
import (
"fmt"
"time"
)
func main() {
result := make(chan int)
go func() {
i := 0
for {
time.Sleep(1 * time.Second)
fmt.Println(i)
i++
if i > 10 {
break
}
}
result <- i
}()
fmt.Println("result => ", <- result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment