File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ import (
6666 "math"
6767 "math/rand"
6868 "reflect"
69- "sort"
7069 "strconv"
7170 "strings"
7271 "sync"
@@ -87,9 +86,9 @@ func init() {
8786 configs : make (map [string ]* pgx.ConnConfig ),
8887 }
8988
90- drivers := sql . Drivers ()
91- // if pgx driver was already registered by different pgx major version then we skip registration under the default name.
92- if i := sort . SearchStrings (sql .Drivers (), "pgx" ); len ( drivers ) >= i || drivers [ i ] != "pgx" {
89+ // if pgx driver was already registered by different pgx major version then we
90+ // skip registration under the default name.
91+ if ! contains (sql .Drivers (), "pgx" ) {
9392 sql .Register ("pgx" , pgxDriver )
9493 }
9594 sql .Register ("pgx/v5" , pgxDriver )
@@ -111,6 +110,17 @@ func init() {
111110 }
112111}
113112
113+ // TODO replace by slices.Contains when experimental package will be merged to stdlib
114+ // https://pkg.go.dev/golang.org/x/exp/slices#Contains
115+ func contains (list []string , y string ) bool {
116+ for _ , x := range list {
117+ if x == y {
118+ return true
119+ }
120+ }
121+ return false
122+ }
123+
114124// OptionOpenDB options for configuring the driver when opening a new db pool.
115125type OptionOpenDB func (* connector )
116126
You can’t perform that action at this time.
0 commit comments