package main
import "fmt"
func fib(ch chan<- int) {
x, y := 0, 1
// infinite loop
for {
ch <- x
x, y = y, x+y
}
}
func main() {
ch := make(chan int)
go fib(ch)
for i := 0; i < 10; i++ {
fmt.Println(<-ch)
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: