Skip to content

Commit

Permalink
Use Go standard library slices&maps packages
Browse files Browse the repository at this point in the history
Use the standard library packages instead of x/exp/{slices,maps}.
The former is available since Go 1.21 and the latter is merely a wrapper
around it when using Go ≥ 1.21. Use the standard library package
directly.

Signed-off-by: Tobias Klauser <[email protected]>
Signed-off-by: Jussi Maki <[email protected]>
  • Loading branch information
tklauser authored and joamaki committed Sep 6, 2024
1 parent b6fa4df commit 271dee5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"flag"
"fmt"
"log"
"maps"
"math/rand"
"os"
"runtime"
Expand All @@ -18,7 +19,6 @@ import (
"github.com/cilium/statedb"
"github.com/cilium/statedb/index"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
)

// Run test with "--debug" for log output.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
go.uber.org/goleak v1.3.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/time v0.5.0
)

Expand All @@ -31,6 +30,7 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/dig v1.17.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
5 changes: 3 additions & 2 deletions graveyard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package statedb

import (
"context"
"maps"
"slices"
"time"

"golang.org/x/exp/maps"
"golang.org/x/time/rate"
)

Expand Down Expand Up @@ -83,7 +84,7 @@ func graveyardWorker(db *DB, ctx context.Context, gcRateLimitInterval time.Durat
}

// Dead objects found, do a write transaction against all tables with dead objects in them.
tablesToModify := maps.Keys(toBeDeleted)
tablesToModify := slices.Collect(maps.Keys(toBeDeleted))
txn = db.WriteTxn(tablesToModify[0], tablesToModify[1:]...).getTxn()
for meta, deadObjs := range toBeDeleted {
tableName := meta.Name()
Expand Down
3 changes: 1 addition & 2 deletions reconciler/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ package reconciler
import (
"errors"
"fmt"

"golang.org/x/exp/slices"
"slices"
)

var closedWatchChannel = func() <-chan struct{} {
Expand Down

0 comments on commit 271dee5

Please sign in to comment.