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 <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2025-03-04 00:46:49 +11:00
committed by GitHub
parent 88f0131abb
commit 04c33968cf
52 changed files with 53 additions and 55 deletions
+1 -1
View File
@@ -14,6 +14,7 @@ import (
"os"
"os/user"
"path/filepath"
"slices"
"sort"
"strconv"
"strings"
@@ -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"
+1 -1
View File
@@ -19,6 +19,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"slices"
"strconv"
"strings"
"sync/atomic"
@@ -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"
+1 -1
View File
@@ -12,6 +12,7 @@ import (
"os/user"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"time"
@@ -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"
+1 -1
View File
@@ -3,6 +3,7 @@ package agenttest
import (
"context"
"io"
"slices"
"sync"
"sync/atomic"
"testing"
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -12,6 +12,7 @@ import (
"net/url"
"os"
"os/signal"
"slices"
"strconv"
"strings"
"sync"
@@ -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"
+1 -1
View File
@@ -17,6 +17,7 @@ import (
"path/filepath"
"runtime"
"runtime/trace"
"slices"
"strings"
"sync"
"syscall"
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
)
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -10,6 +10,7 @@ import (
"math"
"reflect"
"regexp"
"slices"
"sort"
"strings"
"sync"
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -5,11 +5,11 @@ package dbmetrics
import (
"context"
"slices"
"time"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"
"cdr.dev/slog"
"github.com/coder/coder/v2/coderd/database"
+1 -1
View File
@@ -7,6 +7,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"slices"
"testing"
"time"
@@ -14,7 +15,6 @@ import (
"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"
+1 -1
View File
@@ -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
+1 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"sync"
"testing"
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -2
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -9,6 +9,7 @@ import (
"net"
"net/http"
"net/http/httptest"
"slices"
"strings"
"sync/atomic"
"testing"
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -3,13 +3,13 @@ package idpsync_test
import (
"context"
"encoding/json"
"slices"
"testing"
"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"golang.org/x/exp/slices"
"cdr.dev/slog/sloggers/slogtest"
"github.com/coder/coder/v2/coderd/database"
+2 -3
View File
@@ -5,18 +5,17 @@ import (
"database/sql"
"fmt"
"net/http"
"slices"
"strings"
"time"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/db2sdk"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/coderd/rbac/policy"
+1 -1
View File
@@ -2,10 +2,10 @@ package coderd_test
import (
"net/http"
"slices"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"github.com/coder/serpent"
@@ -2,12 +2,12 @@ package insights
import (
"context"
"slices"
"sync/atomic"
"time"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
+1 -1
View File
@@ -4,13 +4,13 @@ import (
"context"
"database/sql"
"encoding/json"
"slices"
"strings"
"sync"
"time"
"github.com/cenkalti/backoff/v4"
"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"cdr.dev/slog"
+1 -1
View File
@@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"slices"
"strings"
"sync"
"testing"
@@ -15,7 +16,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"golang.org/x/exp/slices"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbmem"
@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"reflect"
"slices"
"sort"
"strconv"
"strings"
@@ -20,7 +21,6 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.14.0"
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/oauth2"
"golang.org/x/xerrors"
protobuf "google.golang.org/protobuf/proto"
+1 -1
View File
@@ -7,12 +7,12 @@ import (
"encoding/base64"
"fmt"
"os"
"slices"
"strconv"
"strings"
passwordvalidator "github.com/wagslane/go-password-validator"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/coderd/util/lazy"
+1 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"slices"
"strings"
"testing"
"time"
@@ -19,7 +20,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
+1 -1
View File
@@ -9,6 +9,7 @@ import (
"io"
"net/http"
"net/url"
"slices"
"sort"
"strconv"
"strings"
@@ -17,7 +18,6 @@ import (
"github.com/google/uuid"
"github.com/sqlc-dev/pqtype"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"tailscale.com/tailcfg"
+1 -1
View File
@@ -7,10 +7,10 @@ import (
"net/http"
"net/url"
"path"
"slices"
"strings"
"time"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"github.com/go-jose/go-jose/v4/jwt"
+1 -1
View File
@@ -2,6 +2,7 @@ package workspaceapps_test
import (
"context"
"slices"
"sync"
"sync/atomic"
"testing"
@@ -10,7 +11,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/coderd/database/dbtime"
+1 -1
View File
@@ -7,13 +7,13 @@ import (
"fmt"
"math"
"net/http"
"slices"
"sort"
"strconv"
"time"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
+1 -1
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"slices"
"strconv"
"testing"
"time"
@@ -14,7 +15,6 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"cdr.dev/slog"
+1 -1
View File
@@ -2,12 +2,12 @@ package agentsdk
import (
"context"
"slices"
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
protobuf "google.golang.org/protobuf/proto"
+1 -1
View File
@@ -4,13 +4,13 @@ import (
"context"
"fmt"
"net/http"
"slices"
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
@@ -3,11 +3,11 @@ package healthsdk
import (
"net"
"net/netip"
"slices"
"strings"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"tailscale.com/net/interfaces"
"github.com/coder/coder/v2/coderd/healthcheck/health"
+1 -1
View File
@@ -7,13 +7,13 @@ import (
"io"
"net/http"
"net/http/cookiejar"
"slices"
"strings"
"time"
"github.com/google/uuid"
"github.com/hashicorp/yamux"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/buildinfo"
+1 -1
View File
@@ -3,13 +3,13 @@ package license_test
import (
"context"
"fmt"
"slices"
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbmem"
+1 -1
View File
@@ -8,6 +8,7 @@ import (
"io"
"regexp"
"runtime"
"slices"
"strings"
"sync"
"testing"
@@ -16,7 +17,6 @@ import (
"github.com/acarl005/stripansi"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"github.com/coder/coder/v2/pty"
+1 -1
View File
@@ -7,6 +7,7 @@ import (
"net/http"
"net/http/httptest"
"runtime"
"slices"
"strings"
"sync"
"testing"
@@ -15,7 +16,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
"github.com/coder/coder/v2/agent/agenttest"
"github.com/coder/coder/v2/coderd/coderdtest"
+1 -1
View File
@@ -19,6 +19,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strings"
"sync"
"sync/atomic"
@@ -29,7 +30,6 @@ import (
"github.com/justinas/nosurf"
"github.com/klauspost/compress/zstd"
"github.com/unrolled/secure"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/singleflight"
"golang.org/x/xerrors"
+1 -1
View File
@@ -3,11 +3,11 @@ package tailnet
import (
"context"
"net/netip"
"slices"
"sync"
"time"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"tailscale.com/tailcfg"
"tailscale.com/types/key"
"tailscale.com/wgengine"
+1 -1
View File
@@ -2,13 +2,13 @@ package tailnet
import (
"net/netip"
"slices"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"tailscale.com/tailcfg"
"tailscale.com/types/key"