From 74b63c70c2e77d938a9665d8aae178d082d012e5 Mon Sep 17 00:00:00 2001 From: Erik Unger Date: Thu, 21 Nov 2024 08:32:40 +0100 Subject: [PATCH] db.Now() returns time.Now() in case of an error --- db/query.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/query.go b/db/query.go index 72df431..2d5df95 100644 --- a/db/query.go +++ b/db/query.go @@ -16,8 +16,13 @@ import ( // function for the current connection. // Useful for getting the timestamp of a // SQL transaction for use in Go code. -func Now(ctx context.Context) (time.Time, error) { - return Conn(ctx).Now() +// Returns time.Now() in case of an error. +func Now(ctx context.Context) time.Time { + now, err := Conn(ctx).Now() + if err != nil { + return time.Now() + } + return now } // Exec executes a query with optional args.