The ten sqlclosecheck findings were not leaks: every one of these queries already deferred a close through the package-local CloseRows helper. sqlclosecheck only recognises a Close call on the rows value in the function that produced it (directly deferred, or inside a deferred closure), so a call that hands rows to a helper reads as unhandled. Rather than keep a helper the linter cannot see through, drop CloseRows and defer a closure that calls rows.Close() directly at each of the eighteen call sites, keeping the existing fatal-on-close-error behaviour byte for byte. The close still runs exactly once, on function exit, after the rows have been read. Fatalf stays; it is still used by the transaction helpers.
13 lines
223 B
Go
13 lines
223 B
Go
package database
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// Fatalf prints an error message to stderr and exits with status 1
|
|
func Fatalf(format string, args ...any) {
|
|
fmt.Fprintf(os.Stderr, "FATAL: "+format+"\n", args...)
|
|
os.Exit(1)
|
|
}
|