Proposals Unofficial Go proposal tracker

Report missing Err calls after bufio.Scanner and sql.Rows loops

#17747 · cmd/vet · medium impact · Implemented in Go 1.28 ·

Code that loops over a bufio.Scanner or sql.Rows often forgets to call Err() afterward. The loop then ends silently on an I/O or database error, and the program treats partial results as complete.

A new vet check reports uses of bufio.Scanner where Err() is never called. It skips scanners whose underlying reader cannot fail, such as bytes.Buffer or strings.Reader. A similar analyzer reports missing Err() calls on sql.Rows. Both analyzers run in gopls and are part of the default go vet suite.

s := bufio.NewScanner(f)
for s.Scan() {
    process(s.Text())
}
// vet: s.Err() is never checked
if err := s.Err(); err != nil { // add this
    return err
}
Proposal
#17747 by mdlayher
Status
Implemented on Jul 24, 2026
Release
Go 1.28
Impact
medium
Area
cmd/vet