shad-go/lectures/07-sql/conn/conn.go
2021-04-08 14:32:08 +03:00

17 lines
210 B
Go

package conn
import (
"context"
"database/sql"
"log"
)
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)
}