errcheck
errcheck copied to clipboard
Check for errors returned from iterators
Hi! I was wondering if you thought it would be worthwhile for errcheck to check for unchecked errors returned from iterators? For example, in the following code snippet, the error returned from the iter.Seq2[string, error] is silently elided both times:
package main
import (
"fmt"
"iter"
)
func fallibleIter() iter.Seq2[string, error] {
strs := []string{"a", "b", "c"}
return func(yield func(string, error) bool) {
for _, str := range strs {
if !yield(str, nil) {
return
}
}
}
}
func main() {
for s := range fallibleIter() {
fmt.Println(s)
}
for s, _ := range fallibleIter() {
fmt.Println(s)
}
}