shad-go/lectures/07-sql/resources/ctx.go
Fedor Korotkiy 545540cea9 WIP
2023-02-22 17:02:34 +04:00

19 lines
318 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package resources
import (
"context"
"database/sql"
"log"
)
func NoContext(ctx context.Context, db *sql.DB) {
// У Conn() нет версии без контекста
c, err := db.Conn(ctx)
if err != nil {
log.Fatal(err)
}
defer c.Close()
// Потенциально вечный Ping
_ = db.Ping()
}