package main
import (
"fmt"
)
func fiber(mychan chan int) {
n := cap(mychan)
x, y := 1, 1
for i := 0; i < n; i++ {
mychan <- x
x, y = y, x+y
}
close(mychan)
}
func main() {
pipe := make(chan int, 10)
go fiber(pipe)
for k := range pipe {
fmt.Println(k)
}
}
执行结果: