Auto-remediate style-only findings (wsl_v5, nlreturn, noinlineerr, modernize, intrange, perfsprint, usetesting, unconvert, errorlint, gocritic, testifylint) and rename printf-style helpers to f-suffixed names (goprintffuncname): ui.Writer message methods, cli.ReportErrorf, database.Fatalf, vaultik stdoutf.
22 lines
402 B
Go
22 lines
402 B
Go
package database
|
|
|
|
import (
|
|
"database/sql"
|
|
"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)
|
|
}
|
|
|
|
// CloseRows closes rows and exits on error
|
|
func CloseRows(rows *sql.Rows) {
|
|
err := rows.Close()
|
|
if err != nil {
|
|
Fatalf("failed to close rows: %v", err)
|
|
}
|
|
}
|