Skip to content

Commit

Permalink
Merge pull request #2066 from yuki0920/use-slices-contains
Browse files Browse the repository at this point in the history
Fix: use `slices.Contains` according to the TODO comment
  • Loading branch information
jackc authored Jul 1, 2024
2 parents 6b9ff97 + a764746 commit dd71547
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions stdlib/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import (
"math"
"math/rand"
"reflect"
"slices"
"strconv"
"strings"
"sync"
Expand All @@ -98,7 +99,7 @@ func init() {

// if pgx driver was already registered by different pgx major version then we
// skip registration under the default name.
if !contains(sql.Drivers(), "pgx") {
if !slices.Contains(sql.Drivers(), "pgx") {
sql.Register("pgx", pgxDriver)
}
sql.Register("pgx/v5", pgxDriver)
Expand All @@ -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.
type OptionOpenDB func(*connector)

Expand Down

0 comments on commit dd71547

Please sign in to comment.