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

18 lines
210 B
Go
Raw Normal View History

2021-04-08 11:32:08 +00:00
package conn
2020-04-09 11:15:34 +00:00
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)
}