mirror of https://github.com/jackc/pgx.git
Merge pull request #2066 from yuki0920/use-slices-contains
Fix: use `slices.Contains` according to the TODO commentpull/2067/head
commit
dd71547340
|
@ -75,6 +75,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -98,7 +99,7 @@ func init() {
|
||||||
|
|
||||||
// if pgx driver was already registered by different pgx major version then we
|
// if pgx driver was already registered by different pgx major version then we
|
||||||
// skip registration under the default name.
|
// skip registration under the default name.
|
||||||
if !contains(sql.Drivers(), "pgx") {
|
if !slices.Contains(sql.Drivers(), "pgx") {
|
||||||
sql.Register("pgx", pgxDriver)
|
sql.Register("pgx", pgxDriver)
|
||||||
}
|
}
|
||||||
sql.Register("pgx/v5", pgxDriver)
|
sql.Register("pgx/v5", pgxDriver)
|
||||||
|
@ -120,17 +121,6 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO replace by slices.Contains when experimental package will be merged to stdlib
|
|
||||||
// https://pkg.go.dev/golang.org/x/exp/slices#Contains
|
|
||||||
func contains(list []string, y string) bool {
|
|
||||||
for _, x := range list {
|
|
||||||
if x == y {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// OptionOpenDB options for configuring the driver when opening a new db pool.
|
// OptionOpenDB options for configuring the driver when opening a new db pool.
|
||||||
type OptionOpenDB func(*connector)
|
type OptionOpenDB func(*connector)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue