Check error methods on types
mmwtsn opened this issue · 1 comments
mmwtsn commented
Is there a way to check if the Err
method on a type is called?
For example, the standard library's bufio#Scanner
type:
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
if err := scanner.Err(); err != nil {
fmt.Fprintln(os.Stderr, "reading standard input:", err)
}
}
Removing the if err := scanner.Err()
block is not caught by errcheck.
kisielk commented
No there is not, and I think it's beyond the scope of this tool. I'm not sure it would even be possible to implement this given that Err
could be called at any later point in the program, or dynamically via an interface, etc.