shad-go/lectures/07-sql/conn/conn.go

18 lines
211 B
Go
Raw Normal View History

2020-04-09 11:15:34 +00:00
package query
import (
"context"
"database/sql"
"log"
)
2020-04-08 19:20:23 +00:00
2020-04-09 11:15:34 +00:00
func Conn(ctx context.Context, db *sql.DB) {
c, err := db.Conn(ctx)
if err != nil {
log.Fatal(err)
}
defer c.Close()
_ = c.PingContext(ctx)
}