Skip to content

Commit aa98bb3

Browse files
Replace another custom implementation of slices.Contains (#1180)
Followup of #1176 Signed-off-by: Cristian Greco <cristian@regolo.cc>
1 parent cac5d52 commit aa98bb3

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

cmd/postgres_exporter/datasource.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"net/url"
1919
"os"
2020
"regexp"
21+
"slices"
2122
"strings"
2223

2324
"github.com/prometheus/client_golang/prometheus"
@@ -64,11 +65,11 @@ func (e *Exporter) discoverDatabaseDSNs() []string {
6465
continue
6566
}
6667
for _, databaseName := range databaseNames {
67-
if contains(e.excludeDatabases, databaseName) {
68+
if slices.Contains(e.excludeDatabases, databaseName) {
6869
continue
6970
}
7071

71-
if len(e.includeDatabases) != 0 && !contains(e.includeDatabases, databaseName) {
72+
if len(e.includeDatabases) != 0 && !slices.Contains(e.includeDatabases, databaseName) {
7273
continue
7374
}
7475

cmd/postgres_exporter/util.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ import (
2424
"github.com/lib/pq"
2525
)
2626

27-
func contains(a []string, x string) bool {
28-
for _, n := range a {
29-
if x == n {
30-
return true
31-
}
32-
}
33-
return false
34-
}
35-
3627
// convert a string to the corresponding ColumnUsage
3728
func stringToColumnUsage(s string) (ColumnUsage, error) {
3829
var u ColumnUsage

0 commit comments

Comments
 (0)