The version where yield in Go does work: mySeq := func(yield func(n int) bool) { num := 0 // Initial value to find the first prime for { num = nextPrime(num) if isPrime(num) { yield(num) } } } i = 0 for v := range mySeq { i++ fmt.Println("Prime #", i, ": ", v) if i == 10 { break } }
Hi Could you do something for observability
Like sending metrics to Prometheus for count and latency, maybe a generic way to set it up
Sure, will do!
Is this added to go 1.23?
Thank you! I did not know that. I have been using this kind of generator for a long time now. Should switch to this.
The version where yield in Go does work:
mySeq := func(yield func(n int) bool) {
num := 0 // Initial value to find the first prime
for {
num = nextPrime(num)
if isPrime(num) {
yield(num)
}
}
}
i = 0
for v := range mySeq {
i++
fmt.Println("Prime #", i, ": ", v)
if i == 10 {
break
}
}
Thank you! I made a video on this: ruclips.net/video/S4H4q7aEMuU/видео.html