Slide 112
Slide 112 text
type fib struct {
// buffer is the size of the channel buffer.
buffer int
// ch is the internal channel where numbers are written.
ch chan int
}
func NewFib(b int) (*Fib, error) {
f := new(fib)
f.buffer = b
f.ch = make(chan int, b)
go func(f *Fib) {
for i, j := 0, 1; ; i, j = i+j, i {
f.ch <- i
}
}(f)
return f, nil
}
structs.go