*Concurrent
go through the tour of go
https://tour.golang.org/concurrency/1
Async? Yes. But goroutines can still be tricky, you will face almost the same challanges
package main import "fmt" func generator(start, end, sep int) chan int { o := make(chan int) go func() { defer close(o) for i:=start; i<end; i+=sep { o <- i } }() return o } func main() { for i := range generator(0, 10, 1) { fmt.Println(i) } }
Обсуждают сегодня