...
Package postgres
Package postgres adds a 'cloudsqlpostgres' driver to use when you want
to access a Cloud SQL Database via the go database/sql library.
It is a wrapper over the driver found at github.com/lib/pq.
To use this driver, you can look at an example in
postgres_test package in the hook_test.go file
▾ Example
Example shows how to use cloudsqlpostgres dialer
Code:
db, err := sql.Open("cloudsqlpostgres", "host=project:region:instance user=postgres dbname=postgres password=password sslmode=disable")
if err != nil {
log.Fatal(err)
}
defer db.Close()
var now time.Time
fmt.Println(db.QueryRow("SELECT NOW()").Scan(&now))
fmt.Println(now)
type Driver struct{}
func (*Driver) Open
¶
func (d *Driver) Open(name string) (driver.Conn, error)