diff --git a/.golangci.yml b/.golangci.yml index cc290b334..2eeb6c1c8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -64,6 +64,8 @@ linters-settings: desc: "Use github.com/klauspost/compress instead of gzip" - pkg: "zlib" desc: "Use github.com/klauspost/compress instead of zlib" + - pkg: "golang.org/x/exp/slices" + desc: "Use 'slices' instead." errcheck: exclude-functions: # Don't flag lines such as "io.Copy(io.Discard, resp.Body)". diff --git a/cmd/promtool/tsdb.go b/cmd/promtool/tsdb.go index 4bba8421c..8692a3fec 100644 --- a/cmd/promtool/tsdb.go +++ b/cmd/promtool/tsdb.go @@ -23,6 +23,7 @@ import ( "path/filepath" "runtime" "runtime/pprof" + "slices" "strconv" "strings" "sync" @@ -31,7 +32,6 @@ import ( "github.com/alecthomas/units" "github.com/go-kit/log" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql/parser" diff --git a/go.mod b/go.mod index aa3edbbe5..f2d395442 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( go.uber.org/automaxprocs v1.5.3 go.uber.org/goleak v1.3.0 go.uber.org/multierr v1.11.0 - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a + golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/net v0.21.0 golang.org/x/oauth2 v0.16.0 golang.org/x/sync v0.6.0 diff --git a/model/histogram/generic_test.go b/model/histogram/generic_test.go index 6a22b6f19..b4d6585a8 100644 --- a/model/histogram/generic_test.go +++ b/model/histogram/generic_test.go @@ -15,10 +15,10 @@ package histogram import ( "math" + "slices" "testing" "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" ) func TestGetBound(t *testing.T) { diff --git a/model/histogram/histogram.go b/model/histogram/histogram.go index d40adeb62..d94cf98fa 100644 --- a/model/histogram/histogram.go +++ b/model/histogram/histogram.go @@ -16,9 +16,8 @@ package histogram import ( "fmt" "math" + "slices" "strings" - - "golang.org/x/exp/slices" ) // CounterResetHint contains the known information about a counter reset, diff --git a/model/labels/labels.go b/model/labels/labels.go index a482d2a83..e99824826 100644 --- a/model/labels/labels.go +++ b/model/labels/labels.go @@ -17,10 +17,10 @@ package labels import ( "bytes" + "slices" "strings" "github.com/cespare/xxhash/v2" - "golang.org/x/exp/slices" ) // Labels is a sorted set of labels. Order has to be guaranteed upon diff --git a/model/labels/labels_common.go b/model/labels/labels_common.go index e51001e7d..4c4a87e87 100644 --- a/model/labels/labels_common.go +++ b/model/labels/labels_common.go @@ -16,10 +16,10 @@ package labels import ( "bytes" "encoding/json" + "slices" "strconv" "github.com/prometheus/common/model" - "golang.org/x/exp/slices" ) const ( diff --git a/model/labels/labels_dedupelabels.go b/model/labels/labels_dedupelabels.go index 0cf2eb599..dfc74aa3a 100644 --- a/model/labels/labels_dedupelabels.go +++ b/model/labels/labels_dedupelabels.go @@ -17,12 +17,12 @@ package labels import ( "bytes" + "slices" "strings" "sync" "unsafe" "github.com/cespare/xxhash/v2" - "golang.org/x/exp/slices" ) // Labels is implemented by a SymbolTable and string holding name/value diff --git a/model/labels/labels_stringlabels.go b/model/labels/labels_stringlabels.go index d284cb03c..2e718c2b1 100644 --- a/model/labels/labels_stringlabels.go +++ b/model/labels/labels_stringlabels.go @@ -17,11 +17,11 @@ package labels import ( "reflect" + "slices" "strings" "unsafe" "github.com/cespare/xxhash/v2" - "golang.org/x/exp/slices" ) // Labels is implemented by a single flat string holding name/value pairs. diff --git a/promql/engine.go b/promql/engine.go index cd955ff5e..edc90d21a 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -22,6 +22,7 @@ import ( "math" "reflect" "runtime" + "slices" "sort" "strconv" "strings" @@ -36,7 +37,6 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" diff --git a/promql/functions.go b/promql/functions.go index fe1a5644e..98318fdab 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -16,6 +16,7 @@ package promql import ( "fmt" "math" + "slices" "sort" "strconv" "strings" @@ -24,7 +25,6 @@ import ( "github.com/facette/natsort" "github.com/grafana/regexp" "github.com/prometheus/common/model" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" diff --git a/promql/quantile.go b/promql/quantile.go index f62519f5b..6a225afb1 100644 --- a/promql/quantile.go +++ b/promql/quantile.go @@ -15,10 +15,9 @@ package promql import ( "math" + "slices" "sort" - "golang.org/x/exp/slices" - "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" ) diff --git a/rules/group.go b/rules/group.go index bc59bf859..b8694a255 100644 --- a/rules/group.go +++ b/rules/group.go @@ -17,12 +17,12 @@ import ( "context" "errors" "math" + "slices" "strings" "sync" "time" "go.uber.org/atomic" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/promql/parser" diff --git a/rules/manager.go b/rules/manager.go index 66dcdcf2e..e87d55b1e 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "net/url" + "slices" "strings" "sync" "time" @@ -25,7 +26,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slices" "golang.org/x/sync/semaphore" "github.com/prometheus/prometheus/model/labels" diff --git a/scrape/scrape.go b/scrape/scrape.go index aa2d5538b..6ac3c551c 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -23,6 +23,7 @@ import ( "math" "net/http" "reflect" + "slices" "strconv" "strings" "sync" @@ -34,7 +35,6 @@ import ( config_util "github.com/prometheus/common/config" "github.com/prometheus/common/model" "github.com/prometheus/common/version" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/discovery/targetgroup" diff --git a/storage/merge.go b/storage/merge.go index 38897449b..885560022 100644 --- a/storage/merge.go +++ b/storage/merge.go @@ -19,10 +19,9 @@ import ( "context" "fmt" "math" + "slices" "sync" - "golang.org/x/exp/slices" - "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/tsdb/chunkenc" diff --git a/storage/remote/codec.go b/storage/remote/codec.go index d0d2dd1d9..1228b23f5 100644 --- a/storage/remote/codec.go +++ b/storage/remote/codec.go @@ -20,6 +20,7 @@ import ( "io" "math" "net/http" + "slices" "sort" "strings" "sync" @@ -28,7 +29,6 @@ import ( "github.com/golang/snappy" "github.com/prometheus/common/model" "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/exemplar" "github.com/prometheus/prometheus/model/histogram" diff --git a/storage/remote/read_handler.go b/storage/remote/read_handler.go index 3a99e3360..ffc64c9c3 100644 --- a/storage/remote/read_handler.go +++ b/storage/remote/read_handler.go @@ -17,13 +17,13 @@ import ( "context" "errors" "net/http" + "slices" "strings" "sync" "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/labels" diff --git a/tsdb/block.go b/tsdb/block.go index 7833e187f..abd223e4a 100644 --- a/tsdb/block.go +++ b/tsdb/block.go @@ -22,12 +22,12 @@ import ( "io" "os" "path/filepath" + "slices" "sync" "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/oklog/ulid" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" diff --git a/tsdb/chunks/head_chunks.go b/tsdb/chunks/head_chunks.go index 12c3e7b90..5ba538132 100644 --- a/tsdb/chunks/head_chunks.go +++ b/tsdb/chunks/head_chunks.go @@ -23,13 +23,13 @@ import ( "io" "os" "path/filepath" + "slices" "strconv" "sync" "github.com/dennwc/varint" "github.com/prometheus/client_golang/prometheus" "go.uber.org/atomic" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/tsdb/chunkenc" tsdb_errors "github.com/prometheus/prometheus/tsdb/errors" diff --git a/tsdb/compact.go b/tsdb/compact.go index efe3306c7..b21ac4d31 100644 --- a/tsdb/compact.go +++ b/tsdb/compact.go @@ -21,13 +21,13 @@ import ( "io" "os" "path/filepath" + "slices" "time" "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/oklog/ulid" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunkenc" diff --git a/tsdb/db.go b/tsdb/db.go index e9265c55e..f29315517 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -23,6 +23,7 @@ import ( "math" "os" "path/filepath" + "slices" "strconv" "strings" "sync" @@ -33,7 +34,6 @@ import ( "github.com/oklog/ulid" "github.com/prometheus/client_golang/prometheus" "go.uber.org/atomic" - "golang.org/x/exp/slices" "golang.org/x/sync/errgroup" "github.com/prometheus/prometheus/config" diff --git a/tsdb/exemplar.go b/tsdb/exemplar.go index 805de70da..3dd784c62 100644 --- a/tsdb/exemplar.go +++ b/tsdb/exemplar.go @@ -16,11 +16,11 @@ package tsdb import ( "context" "errors" + "slices" "sync" "unicode/utf8" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/exemplar" diff --git a/tsdb/head_read.go b/tsdb/head_read.go index 457d3e1c4..10a462392 100644 --- a/tsdb/head_read.go +++ b/tsdb/head_read.go @@ -18,10 +18,10 @@ import ( "errors" "fmt" "math" + "slices" "sync" "github.com/go-kit/log/level" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" diff --git a/tsdb/index/index.go b/tsdb/index/index.go index 4241ba828..7aae4c264 100644 --- a/tsdb/index/index.go +++ b/tsdb/index/index.go @@ -25,11 +25,10 @@ import ( "math" "os" "path/filepath" + "slices" "sort" "unsafe" - "golang.org/x/exp/slices" - "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunks" diff --git a/tsdb/index/postings.go b/tsdb/index/postings.go index 222a8b0d6..61a5560ee 100644 --- a/tsdb/index/postings.go +++ b/tsdb/index/postings.go @@ -20,12 +20,12 @@ import ( "fmt" "math" "runtime" + "slices" "sort" "strings" "sync" "github.com/bboreham/go-loser" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" diff --git a/tsdb/index/postingsstats.go b/tsdb/index/postingsstats.go index 0ad4e0857..f9ee640ff 100644 --- a/tsdb/index/postingsstats.go +++ b/tsdb/index/postingsstats.go @@ -15,8 +15,7 @@ package index import ( "math" - - "golang.org/x/exp/slices" + "slices" ) // Stat holds values for a single cardinality statistic. diff --git a/tsdb/ooo_head_read.go b/tsdb/ooo_head_read.go index 3a801bf98..c9fe5cd58 100644 --- a/tsdb/ooo_head_read.go +++ b/tsdb/ooo_head_read.go @@ -17,9 +17,9 @@ import ( "context" "errors" "math" + "slices" "github.com/oklog/ulid" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" diff --git a/tsdb/ooo_head_read_test.go b/tsdb/ooo_head_read_test.go index 36289056b..1716f29b5 100644 --- a/tsdb/ooo_head_read_test.go +++ b/tsdb/ooo_head_read_test.go @@ -17,12 +17,12 @@ import ( "context" "fmt" "math" + "slices" "sort" "testing" "time" "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" diff --git a/tsdb/querier.go b/tsdb/querier.go index ab2c53d70..6fc2758db 100644 --- a/tsdb/querier.go +++ b/tsdb/querier.go @@ -18,11 +18,11 @@ import ( "errors" "fmt" "math" + "slices" "strings" "unicode/utf8" "github.com/oklog/ulid" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" diff --git a/tsdb/wlog/checkpoint.go b/tsdb/wlog/checkpoint.go index a49ed1a0c..4ad1bb236 100644 --- a/tsdb/wlog/checkpoint.go +++ b/tsdb/wlog/checkpoint.go @@ -21,12 +21,12 @@ import ( "math" "os" "path/filepath" + "slices" "strconv" "strings" "github.com/go-kit/log" "github.com/go-kit/log/level" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/tsdb/chunks" diff --git a/tsdb/wlog/watcher.go b/tsdb/wlog/watcher.go index a4c46bbaa..b92494468 100644 --- a/tsdb/wlog/watcher.go +++ b/tsdb/wlog/watcher.go @@ -20,6 +20,7 @@ import ( "math" "os" "path/filepath" + "slices" "strconv" "strings" "time" @@ -27,7 +28,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/timestamp" diff --git a/tsdb/wlog/wlog.go b/tsdb/wlog/wlog.go index fdea75694..577057fd4 100644 --- a/tsdb/wlog/wlog.go +++ b/tsdb/wlog/wlog.go @@ -23,6 +23,7 @@ import ( "io" "os" "path/filepath" + "slices" "strconv" "sync" "time" @@ -32,7 +33,6 @@ import ( "github.com/golang/snappy" "github.com/klauspost/compress/zstd" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/tsdb/fileutil" ) diff --git a/util/stats/timer.go b/util/stats/timer.go index b7d79f412..eca0fcccb 100644 --- a/util/stats/timer.go +++ b/util/stats/timer.go @@ -16,9 +16,8 @@ package stats import ( "bytes" "fmt" + "slices" "time" - - "golang.org/x/exp/slices" ) // A Timer that can be started and stopped and accumulates the total time it diff --git a/web/api/v1/api.go b/web/api/v1/api.go index fcb55026e..59e20004c 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -24,6 +24,7 @@ import ( "net/url" "os" "path/filepath" + "slices" "sort" "strconv" "strings" @@ -37,7 +38,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/common/route" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/labels" diff --git a/web/federate.go b/web/federate.go index e0bfc6ee2..8176eba36 100644 --- a/web/federate.go +++ b/web/federate.go @@ -17,6 +17,7 @@ import ( "errors" "fmt" "net/http" + "slices" "sort" "strings" @@ -26,7 +27,6 @@ import ( dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" "github.com/prometheus/common/model" - "golang.org/x/exp/slices" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels"