aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/postgres.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2019-11-21 19:34:23 -0500
committerJulie Qiu <julie@golang.org>2020-03-27 16:46:48 -0400
commit723f3612d1f5a8957fc5210e20f47dbd372e1bb6 (patch)
tree9f77b5b29ba1ef7f0bde0f33c5fd462d0badf1b7 /internal/postgres/postgres.go
parent78700411eaef35e79a588d7a7e8b5de08b80486c (diff)
downloadgo-x-pkgsite-723f3612d1f5a8957fc5210e20f47dbd372e1bb6.tar.xz
internal/postgres: replace Open with New(db)
The constructor for a postgres.DB takes a *database.DB instead of a driver and connection string. Change-Id: Ief58ce676946fd34cbcafc2b634a772663b6f932 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/604403 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
Diffstat (limited to 'internal/postgres/postgres.go')
-rw-r--r--internal/postgres/postgres.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/internal/postgres/postgres.go b/internal/postgres/postgres.go
index d437838a..49e4031b 100644
--- a/internal/postgres/postgres.go
+++ b/internal/postgres/postgres.go
@@ -14,14 +14,9 @@ type DB struct {
db *database.DB
}
-// Open opens a new postgres DB.
-// TODO(jba): take a *sql.DB.
-func Open(driverName, dbinfo string) (*DB, error) {
- db, err := database.Open(driverName, dbinfo)
- if err != nil {
- return nil, err
- }
- return &DB{db}, nil
+// New returns a new postgres DB.
+func New(db *database.DB) *DB {
+ return &DB{db}
}
// Close closes a DB.