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:
parent
8993a6dcb7
commit
4008b9aa25
2 changed files with 5 additions and 3 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue