ducky/subscriptions
2015-09-27
Parent:f1a22fc2321d
ducky/subscriptions/postgres.go
Fix go vet errors. We had a few logging statements that used placeholders but didn't provide any variables to fill them. We now specify the appropriate variables.
1 package subscriptions
3 import (
4 "database/sql"
5 )
7 // NewPostgres returns a usable Postgres instance, if and only
8 // if error is nil. If error is not nil, the returned Postgres
9 // instance should not be used.
10 func NewPostgres(conn string) (Postgres, error) {
11 db, err := sql.Open("postgres", conn)
12 if err != nil {
13 return Postgres{}, err
14 }
15 return Postgres{db}, nil
16 }
18 // Postgres represents a thin wrapper around *sql.DB, so we can
19 // inherit its methods but also define our own (so we can fulfill
20 // our subscriptionStore interface on Postgres). Note that the
21 // value of a Postgres variable contains a _pointer_ to an sql.DB
22 // pool of connections, so it's not necessary to use the address of
23 // the Postgres variable itself (though there shouldn't be any harm
24 // in doing so).
25 type Postgres struct {
26 *sql.DB
27 }