Skip to content

Commit 73d66ae

Browse files
committed
remove db.Now
1 parent 17d4eaf commit 73d66ae

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

db/utils.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"io"
99
"os"
10-
"time"
1110
"unicode/utf8"
1211

1312
"github.com/domonda/go-sqldb"
@@ -26,19 +25,6 @@ func IsOtherThanErrNoRows(err error) bool {
2625
return sqldb.IsOtherThanErrNoRows(err)
2726
}
2827

29-
// Now returns the result of the SQL now() function
30-
// using the sqldb.Connection from the passed context.
31-
// This is useful to get the timestamp of a
32-
// SQL transaction for use in Go code.
33-
func Now(ctx context.Context) (time.Time, error) {
34-
var now time.Time
35-
err := Conn(ctx).QueryRow(`select now()`).Scan(&now)
36-
if err != nil {
37-
return time.Time{}, err
38-
}
39-
return now, nil
40-
}
41-
4228
// DebugPrintConn prints a line to stderr using the passed args
4329
// and appending the transaction state of the connection
4430
// and the current time of the database using `select now()`
@@ -51,7 +37,7 @@ func DebugPrintConn(ctx context.Context, args ...any) {
5137
args = append(args, "Isolation", optsStr)
5238
}
5339
}
54-
now, err := Now(ctx)
40+
now, err := Conn(ctx).Now()
5541
if err == nil {
5642
args = append(args, "NOW():", now)
5743
} else {

0 commit comments

Comments
 (0)