lint: fix errcheck for txn.Rollback/Commit and r.Close

Use lint.LogOnErrRollback for deferred Rollback in test-jet.
Use lint.LogOnErrCtx for Commit in test-jet.
Use lint.LogOnErr for r.Close in ExecuteNoneTxBob.
This commit is contained in:
Eli Ribble 2026-05-09 02:14:47 +00:00
parent 8993a6dcb7
commit 4008b9aa25
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/config"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/query/public"
"github.com/Gleipnir-Technology/nidus-sync/lint"
)
func main() {
@ -28,7 +29,7 @@ func main() {
log.Printf("failed on txn: %v", err)
os.Exit(3)
}
defer txn.Rollback(ctx)
defer lint.LogOnErrRollback(txn.Rollback, ctx, "rollback")
log.Printf("doing address")
gid := "openaddresses:address:us/ca/tulare-addresses-county:0dc28458fd03e3fa"
address, err := public.AddressFromGID(ctx, txn, gid)
@ -38,7 +39,7 @@ func main() {
}
//log.Printf("address %d lat %f lng %f", address.ID, *address.LocationLatitude, *address.LocationLongitude)
log.Printf("Address id %d location %s", address.ID, address.Location)
txn.Commit(ctx)
lint.LogOnErrCtx(txn.Commit, ctx, "commit")
/*
log.Printf("doing comm")

View file

@ -12,6 +12,7 @@ import (
//"github.com/jackc/pgx/v5"
"github.com/Gleipnir-Technology/bob"
"github.com/Gleipnir-Technology/jet/postgres"
"github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/jackc/pgx/v5/stdlib"
@ -58,7 +59,7 @@ func ExecuteNoneTxBob(ctx context.Context, txn bob.Tx, stmt postgres.Statement)
if err != nil {
return fmt.Errorf("query: %w", err)
}
r.Close()
defer lint.LogOnErr(r.Close, "close rows")
return nil
}
func ExecuteOne[T any](ctx context.Context, stmt postgres.Statement) (T, error) {