if err := db.Ping(ctx); err != nil { // do something with error }