Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04c3396

Browse files
authored
refactor: replace golang.org/x/exp/slices with slices (#16772)
The experimental functions in `golang.org/x/exp/slices` are now available in the standard library since Go 1.21. Reference: https://go.dev/doc/go1.21#slices Signed-off-by: Eng Zer Jun <[email protected]>
1 parent 88f0131 commit 04c3396

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+53
-55
lines changed

agent/agent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"os"
1515
"os/user"
1616
"path/filepath"
17+
"slices"
1718
"sort"
1819
"strconv"
1920
"strings"
@@ -26,7 +27,6 @@ import (
2627
"github.com/prometheus/common/expfmt"
2728
"github.com/spf13/afero"
2829
"go.uber.org/atomic"
29-
"golang.org/x/exp/slices"
3030
"golang.org/x/sync/errgroup"
3131
"golang.org/x/xerrors"
3232
"google.golang.org/protobuf/types/known/timestamppb"

agent/agent_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"path/filepath"
2020
"regexp"
2121
"runtime"
22+
"slices"
2223
"strconv"
2324
"strings"
2425
"sync/atomic"
@@ -41,7 +42,6 @@ import (
4142
"github.com/stretchr/testify/assert"
4243
"github.com/stretchr/testify/require"
4344
"golang.org/x/crypto/ssh"
44-
"golang.org/x/exp/slices"
4545
"golang.org/x/xerrors"
4646

4747
"cdr.dev/slog"

agent/agentssh/agentssh.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os/user"
1313
"path/filepath"
1414
"runtime"
15+
"slices"
1516
"strings"
1617
"sync"
1718
"time"
@@ -24,7 +25,6 @@ import (
2425
"github.com/spf13/afero"
2526
"go.uber.org/atomic"
2627
gossh "golang.org/x/crypto/ssh"
27-
"golang.org/x/exp/slices"
2828
"golang.org/x/xerrors"
2929

3030
"cdr.dev/slog"

agent/agenttest/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package agenttest
33
import (
44
"context"
55
"io"
6+
"slices"
67
"sync"
78
"sync/atomic"
89
"testing"
@@ -12,7 +13,6 @@ import (
1213
"github.com/stretchr/testify/assert"
1314
"github.com/stretchr/testify/require"
1415
"golang.org/x/exp/maps"
15-
"golang.org/x/exp/slices"
1616
"golang.org/x/xerrors"
1717
"google.golang.org/protobuf/types/known/durationpb"
1818
"google.golang.org/protobuf/types/known/emptypb"

agent/reconnectingpty/buffered.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"errors"
66
"io"
77
"net"
8+
"slices"
89
"time"
910

1011
"github.com/armon/circbuf"
1112
"github.com/prometheus/client_golang/prometheus"
12-
"golang.org/x/exp/slices"
1313
"golang.org/x/xerrors"
1414

1515
"cdr.dev/slog"

cli/configssh.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os"
1212
"path/filepath"
1313
"runtime"
14+
"slices"
1415
"strconv"
1516
"strings"
1617

@@ -19,7 +20,6 @@ import (
1920
"github.com/pkg/diff"
2021
"github.com/pkg/diff/write"
2122
"golang.org/x/exp/constraints"
22-
"golang.org/x/exp/slices"
2323
"golang.org/x/xerrors"
2424

2525
"github.com/coder/coder/v2/cli/cliui"

cli/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"fmt"
66
"io"
7+
"slices"
78
"strings"
89
"time"
910

1011
"github.com/google/uuid"
11-
"golang.org/x/exp/slices"
1212
"golang.org/x/xerrors"
1313

1414
"github.com/coder/pretty"

cli/exp_scaletest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"net/url"
1313
"os"
1414
"os/signal"
15+
"slices"
1516
"strconv"
1617
"strings"
1718
"sync"
@@ -21,7 +22,6 @@ import (
2122
"github.com/prometheus/client_golang/prometheus"
2223
"github.com/prometheus/client_golang/prometheus/promhttp"
2324
"go.opentelemetry.io/otel/trace"
24-
"golang.org/x/exp/slices"
2525
"golang.org/x/xerrors"
2626

2727
"cdr.dev/slog"

cli/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"path/filepath"
1818
"runtime"
1919
"runtime/trace"
20+
"slices"
2021
"strings"
2122
"sync"
2223
"syscall"
@@ -25,7 +26,6 @@ import (
2526

2627
"github.com/mattn/go-isatty"
2728
"github.com/mitchellh/go-wordwrap"
28-
"golang.org/x/exp/slices"
2929
"golang.org/x/mod/semver"
3030
"golang.org/x/xerrors"
3131

cli/tokens.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package cli
33
import (
44
"fmt"
55
"os"
6+
"slices"
67
"strings"
78
"time"
89

9-
"golang.org/x/exp/slices"
1010
"golang.org/x/xerrors"
1111

1212
"github.com/coder/coder/v2/cli/cliui"

coderd/agentapi/lifecycle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package agentapi
33
import (
44
"context"
55
"database/sql"
6+
"slices"
67
"time"
78

89
"github.com/google/uuid"
9-
"golang.org/x/exp/slices"
1010
"golang.org/x/mod/semver"
1111
"golang.org/x/xerrors"
1212
"google.golang.org/protobuf/types/known/timestamppb"

coderd/audit/audit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package audit
22

33
import (
44
"context"
5+
"slices"
56
"sync"
67
"testing"
78

89
"github.com/google/uuid"
9-
"golang.org/x/exp/slices"
1010

1111
"github.com/coder/coder/v2/coderd/database"
1212
)

coderd/database/db2sdk/db2sdk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/url"
8+
"slices"
89
"sort"
910
"strconv"
1011
"strings"
1112
"time"
1213

1314
"github.com/google/uuid"
14-
"golang.org/x/exp/slices"
1515
"golang.org/x/xerrors"
1616
"tailscale.com/tailcfg"
1717

coderd/database/dbauthz/dbauthz.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"database/sql"
66
"encoding/json"
77
"errors"
8+
"slices"
89
"strings"
910
"sync/atomic"
1011
"testing"
1112
"time"
1213

1314
"github.com/google/uuid"
14-
"golang.org/x/exp/slices"
1515
"golang.org/x/xerrors"
1616

1717
"github.com/open-policy-agent/opa/topdown"

coderd/database/dbmem/dbmem.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"math"
1111
"reflect"
1212
"regexp"
13+
"slices"
1314
"sort"
1415
"strings"
1516
"sync"
@@ -19,7 +20,6 @@ import (
1920
"github.com/lib/pq"
2021
"golang.org/x/exp/constraints"
2122
"golang.org/x/exp/maps"
22-
"golang.org/x/exp/slices"
2323
"golang.org/x/xerrors"
2424

2525
"github.com/coder/coder/v2/coderd/notifications/types"

coderd/database/dbmetrics/dbmetrics.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package dbmetrics
22

33
import (
44
"context"
5+
"slices"
56
"strconv"
67
"time"
78

89
"github.com/prometheus/client_golang/prometheus"
9-
"golang.org/x/exp/slices"
1010

1111
"cdr.dev/slog"
1212
"github.com/coder/coder/v2/coderd/database"

coderd/database/dbmetrics/querymetrics.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbpurge/dbpurge_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import (
77
"database/sql"
88
"encoding/json"
99
"fmt"
10+
"slices"
1011
"testing"
1112
"time"
1213

1314
"github.com/google/uuid"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
1617
"go.uber.org/goleak"
17-
"golang.org/x/exp/slices"
1818

1919
"cdr.dev/slog"
2020
"cdr.dev/slog/sloggers/slogtest"

coderd/database/gentest/modelqueries_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import (
55
"go/ast"
66
"go/parser"
77
"go/token"
8+
"slices"
89
"testing"
910

1011
"github.com/stretchr/testify/assert"
1112
"github.com/stretchr/testify/require"
12-
"golang.org/x/exp/slices"
1313
)
1414

1515
// TestCustomQueriesSynced makes sure the manual custom queries in modelqueries.go

coderd/database/migrations/migrate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"path/filepath"
9+
"slices"
910
"sync"
1011
"testing"
1112

@@ -17,7 +18,6 @@ import (
1718
"github.com/lib/pq"
1819
"github.com/stretchr/testify/require"
1920
"go.uber.org/goleak"
20-
"golang.org/x/exp/slices"
2121
"golang.org/x/sync/errgroup"
2222

2323
"github.com/coder/coder/v2/coderd/database/dbtestutil"

coderd/debug.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"encoding/json"
88
"fmt"
99
"net/http"
10+
"slices"
1011
"time"
1112

1213
"github.com/google/uuid"
13-
"golang.org/x/exp/slices"
1414
"golang.org/x/xerrors"
1515

1616
"cdr.dev/slog"

coderd/devtunnel/servers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package devtunnel
22

33
import (
44
"runtime"
5+
"slices"
56
"sync"
67
"time"
78

89
ping "github.com/prometheus-community/pro-bing"
9-
"golang.org/x/exp/slices"
1010
"golang.org/x/sync/errgroup"
1111
"golang.org/x/xerrors"
1212

coderd/entitlements/entitlements.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"context"
55
"encoding/json"
66
"net/http"
7+
"slices"
78
"sync"
89
"time"
910

10-
"golang.org/x/exp/slices"
1111
"golang.org/x/xerrors"
1212

1313
"github.com/coder/coder/v2/codersdk"

coderd/healthcheck/database.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package healthcheck
22

33
import (
44
"context"
5+
"slices"
56
"time"
67

7-
"golang.org/x/exp/slices"
8-
98
"github.com/coder/coder/v2/coderd/database"
109
"github.com/coder/coder/v2/coderd/healthcheck/health"
1110
"github.com/coder/coder/v2/codersdk/healthsdk"

coderd/healthcheck/derphealth/derp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"net"
77
"net/netip"
88
"net/url"
9+
"slices"
910
"strings"
1011
"sync"
1112
"sync/atomic"
1213
"time"
1314

14-
"golang.org/x/exp/slices"
1515
"golang.org/x/xerrors"
1616
"tailscale.com/derp"
1717
"tailscale.com/derp/derphttp"

coderd/httpmw/apikey_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net"
1010
"net/http"
1111
"net/http/httptest"
12+
"slices"
1213
"strings"
1314
"sync/atomic"
1415
"testing"
@@ -17,7 +18,6 @@ import (
1718
"github.com/google/uuid"
1819
"github.com/stretchr/testify/assert"
1920
"github.com/stretchr/testify/require"
20-
"golang.org/x/exp/slices"
2121
"golang.org/x/oauth2"
2222

2323
"github.com/coder/coder/v2/coderd/database"

coderd/idpsync/group_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"context"
55
"database/sql"
66
"regexp"
7+
"slices"
78
"testing"
89

910
"github.com/golang-jwt/jwt/v4"
1011
"github.com/google/uuid"
1112
"github.com/stretchr/testify/require"
12-
"golang.org/x/exp/slices"
1313
"golang.org/x/xerrors"
1414

1515
"cdr.dev/slog/sloggers/slogtest"

coderd/idpsync/role.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package idpsync
33
import (
44
"context"
55
"encoding/json"
6+
"slices"
67

78
"github.com/golang-jwt/jwt/v4"
89
"github.com/google/uuid"
9-
"golang.org/x/exp/slices"
1010
"golang.org/x/xerrors"
1111

1212
"cdr.dev/slog"

0 commit comments

Comments
 (0)