Skip to content

refactor: replace golang.org/x/exp/slices with slices #16772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: replace golang.org/x/exp/slices with slices
The experimental functions in `golang.org/x/exp/slices` are now
available in the standard library in Go 1.21.

Reference: https://go.dev/doc/go1.21#slices
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
  • Loading branch information
Juneezee committed Mar 3, 2025
commit c22abecccb01d03d01b0829f35ead627c5b42a13
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"os"
"os/user"
"path/filepath"
"slices"
"sort"
"strconv"
"strings"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/prometheus/common/expfmt"
"github.com/spf13/afero"
"go.uber.org/atomic"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down
2 changes: 1 addition & 1 deletion agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"slices"
"strconv"
"strings"
"sync/atomic"
Expand All @@ -41,7 +42,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog"
Expand Down
2 changes: 1 addition & 1 deletion agent/agentssh/agentssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/user"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"time"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/spf13/afero"
"go.uber.org/atomic"
gossh "golang.org/x/crypto/ssh"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog"
Expand Down
2 changes: 1 addition & 1 deletion agent/agenttest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package agenttest
import (
"context"
"io"
"slices"
"sync"
"sync/atomic"
"testing"
Expand All @@ -12,7 +13,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/emptypb"
Expand Down
2 changes: 1 addition & 1 deletion agent/reconnectingpty/buffered.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"errors"
"io"
"net"
"slices"
"time"

"github.com/armon/circbuf"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog"
Expand Down
2 changes: 1 addition & 1 deletion cli/configssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"

Expand All @@ -19,7 +20,6 @@ import (
"github.com/pkg/diff"
"github.com/pkg/diff/write"
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"github.com/coder/coder/v2/cli/cliui"
Expand Down
2 changes: 1 addition & 1 deletion cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"fmt"
"io"
"slices"
"strings"
"time"

"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"github.com/coder/pretty"
Expand Down
2 changes: 1 addition & 1 deletion cli/exp_scaletest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"
"os"
"os/signal"
"slices"
"strconv"
"strings"
"sync"
Expand All @@ -21,7 +22,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog"
Expand Down
2 changes: 1 addition & 1 deletion cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"path/filepath"
"runtime"
"runtime/trace"
"slices"
"strings"
"sync"
"syscall"
Expand All @@ -25,7 +26,6 @@ import (

"github.com/mattn/go-isatty"
"github.com/mitchellh/go-wordwrap"
"golang.org/x/exp/slices"
"golang.org/x/mod/semver"
"golang.org/x/xerrors"

Expand Down
2 changes: 1 addition & 1 deletion cli/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package cli
import (
"fmt"
"os"
"slices"
"strings"
"time"

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

"github.com/coder/coder/v2/cli/cliui"
Expand Down
2 changes: 1 addition & 1 deletion coderd/agentapi/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package agentapi
import (
"context"
"database/sql"
"slices"
"time"

"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/mod/semver"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down
2 changes: 1 addition & 1 deletion coderd/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package audit

import (
"context"
"slices"
"sync"
"testing"

"github.com/google/uuid"
"golang.org/x/exp/slices"

"github.com/coder/coder/v2/coderd/database"
)
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"encoding/json"
"fmt"
"net/url"
"slices"
"sort"
"strconv"
"strings"
"time"

"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"tailscale.com/tailcfg"

Expand Down
2 changes: 1 addition & 1 deletion coderd/database/dbauthz/dbauthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"database/sql"
"encoding/json"
"errors"
"slices"
"strings"
"sync/atomic"
"testing"
"time"

"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"github.com/open-policy-agent/opa/topdown"
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"math"
"reflect"
"regexp"
"slices"
"sort"
"strings"
"sync"
Expand All @@ -19,7 +20,6 @@ import (
"github.com/lib/pq"
"golang.org/x/exp/constraints"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"github.com/coder/coder/v2/coderd/notifications/types"
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/dbmetrics/dbmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package dbmetrics

import (
"context"
"slices"
"strconv"
"time"

"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"

"cdr.dev/slog"
"github.com/coder/coder/v2/coderd/database"
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/dbmetrics/querymetrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion coderd/database/dbpurge/dbpurge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"database/sql"
"encoding/json"
"fmt"
"slices"
"testing"
"time"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"golang.org/x/exp/slices"

"cdr.dev/slog"
"cdr.dev/slog/sloggers/slogtest"
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/gentest/modelqueries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"go/ast"
"go/parser"
"go/token"
"slices"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
)

// TestCustomQueriesSynced makes sure the manual custom queries in modelqueries.go
Expand Down
2 changes: 1 addition & 1 deletion coderd/database/migrations/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"sync"
"testing"

Expand All @@ -17,7 +18,6 @@ import (
"github.com/lib/pq"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"

"github.com/coder/coder/v2/coderd/database/dbtestutil"
Expand Down
2 changes: 1 addition & 1 deletion coderd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"encoding/json"
"fmt"
"net/http"
"slices"
"time"

"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog"
Expand Down
2 changes: 1 addition & 1 deletion coderd/devtunnel/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package devtunnel

import (
"runtime"
"slices"
"sync"
"time"

ping "github.com/prometheus-community/pro-bing"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"

Expand Down
2 changes: 1 addition & 1 deletion coderd/entitlements/entitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"encoding/json"
"net/http"
"slices"
"sync"
"time"

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

"github.com/coder/coder/v2/codersdk"
Expand Down
3 changes: 1 addition & 2 deletions coderd/healthcheck/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package healthcheck

import (
"context"
"slices"
"time"

"golang.org/x/exp/slices"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/healthcheck/health"
"github.com/coder/coder/v2/codersdk/healthsdk"
Expand Down
2 changes: 1 addition & 1 deletion coderd/healthcheck/derphealth/derp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"net"
"net/netip"
"net/url"
"slices"
"strings"
"sync"
"sync/atomic"
"time"

"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"tailscale.com/derp"
"tailscale.com/derp/derphttp"
Expand Down
2 changes: 1 addition & 1 deletion coderd/httpmw/apikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net"
"net/http"
"net/http/httptest"
"slices"
"strings"
"sync/atomic"
"testing"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/oauth2"

"github.com/coder/coder/v2/coderd/database"
Expand Down
2 changes: 1 addition & 1 deletion coderd/idpsync/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"database/sql"
"regexp"
"slices"
"testing"

"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog/sloggers/slogtest"
Expand Down
2 changes: 1 addition & 1 deletion coderd/idpsync/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package idpsync
import (
"context"
"encoding/json"
"slices"

"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

"cdr.dev/slog"
Expand Down
Loading
Loading