Skip to content

Commit

Permalink
Use pkg slices from the standard library (#35905)
Browse files Browse the repository at this point in the history
Prefer the stdlib version of the experimental package.
Includes a depguard update to prevent future regressions,
as well as an e-ref update to appease depguard.

Generated with:

    $ gofmt -w -r '"golang.org/x/exp/slices" -> "slices"' . && \
        make fix-imports
  • Loading branch information
zmb3 authored Dec 19, 2023
1 parent b2fae64 commit 44a6bb1
Show file tree
Hide file tree
Showing 155 changed files with 162 additions and 156 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ linters-settings:
desc: 'use "sync/atomic" instead'
- pkg: golang.design
desc: 'experimental project, not to be confused with official Go packages'
- pkg: golang.org/x/exp/slices
desc: 'use "slices" instead'
gci:
sections:
- standard # Standard section: captures all standard packages.
Expand Down
2 changes: 1 addition & 1 deletion api/client/proxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
"crypto/tls"
"encoding/asn1"
"net"
"slices"
"sync/atomic"
"time"

"github.com/gravitational/trace"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
Expand Down
2 changes: 1 addition & 1 deletion api/client/proxy/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"net"
"slices"
"testing"
"time"

Expand All @@ -34,7 +35,6 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
Expand Down
2 changes: 1 addition & 1 deletion api/client/webclient/webclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import (
"net"
"net/http"
"net/http/httptest"
"slices"
"strings"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/defaults"
apihelpers "github.com/gravitational/teleport/api/testhelpers"
Expand Down
2 changes: 1 addition & 1 deletion api/types/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package types

import (
"fmt"
"slices"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/utils"
Expand Down
2 changes: 1 addition & 1 deletion api/types/header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
package header

import (
"slices"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/types/common"
"github.com/gravitational/teleport/api/utils"
Expand Down
2 changes: 1 addition & 1 deletion api/types/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ limitations under the License.
package types

import (
"slices"
"strings"
"time"

"github.com/coreos/go-semver/semver"
"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/utils"
Expand Down
2 changes: 1 addition & 1 deletion api/types/jamf.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package types

import (
"net/url"
"slices"
"strings"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion api/types/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package types
import (
"fmt"
"regexp"
"slices"
"sort"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/utils"
)
Expand Down
3 changes: 2 additions & 1 deletion api/types/matchers_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package types

import (
"slices"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

apiutils "github.com/gravitational/teleport/api/utils"
awsapiutils "github.com/gravitational/teleport/api/utils/aws"
Expand Down
3 changes: 2 additions & 1 deletion api/types/matchers_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package types

import (
"slices"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

apiutils "github.com/gravitational/teleport/api/utils"
)
Expand Down
3 changes: 2 additions & 1 deletion api/types/matchers_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package types

import (
"slices"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

apiutils "github.com/gravitational/teleport/api/utils"
)
Expand Down
3 changes: 2 additions & 1 deletion api/types/matchers_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package types

import (
"slices"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

apiutils "github.com/gravitational/teleport/api/utils"
)
Expand Down
2 changes: 1 addition & 1 deletion api/types/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package types

import (
"net/url"
"slices"
"time"

"github.com/gravitational/trace"
"golang.org/x/crypto/ssh"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/defaults"
Expand Down
2 changes: 1 addition & 1 deletion api/types/provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package types

import (
"fmt"
"slices"
"strings"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/defaults"
apiutils "github.com/gravitational/teleport/api/utils"
Expand Down
2 changes: 1 addition & 1 deletion api/types/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ package types

import (
"regexp"
"slices"
"sort"
"strings"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/defaults"
"github.com/gravitational/teleport/api/types/common"
Expand Down
2 changes: 1 addition & 1 deletion api/types/resource_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package types
import (
"encoding/json"
"fmt"
"slices"
"strings"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"
)

func (id *ResourceID) CheckAndSetDefaults() error {
Expand Down
2 changes: 1 addition & 1 deletion api/types/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"encoding/json"
"fmt"
"path"
"slices"
"time"

"github.com/gogo/protobuf/proto"
"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/defaults"
Expand Down
2 changes: 1 addition & 1 deletion api/types/saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ limitations under the License.
package types

import (
"slices"
"strings"
"time"

"github.com/gravitational/trace"
"golang.org/x/crypto/ssh"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/defaults"
Expand Down
2 changes: 1 addition & 1 deletion api/types/session_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
package types

import (
"slices"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"

"github.com/gravitational/teleport/api/defaults"
)
Expand Down
2 changes: 1 addition & 1 deletion api/types/sessionrecording.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package types

import (
"slices"
"strings"
"time"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"
)

// SessionRecordingConfig defines session recording configuration. This is
Expand Down
2 changes: 1 addition & 1 deletion api/types/trustedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package types

import (
"fmt"
"slices"
"time"

"github.com/google/go-cmp/cmp"
"github.com/gravitational/trace"
"golang.org/x/exp/slices"
)

// TrustedCluster holds information needed for a cluster that can not be directly
Expand Down
2 changes: 1 addition & 1 deletion api/utils/aws/identifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package aws

import (
"regexp"
"slices"
"strings"

"github.com/gravitational/trace"
"golang.org/x/exp/slices"
)

// IsValidAccountID checks whether the accountID is a valid AWS Account ID
Expand Down
2 changes: 1 addition & 1 deletion api/utils/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ package utils

import (
"net"
"slices"
"unicode/utf8"

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

"github.com/gravitational/teleport/api/utils/aws"
)
Expand Down
2 changes: 1 addition & 1 deletion build.assets/tooling/cmd/difftest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strings"
"time"

"github.com/alecthomas/kingpin/v2"
"github.com/gravitational/trace"
"golang.org/x/exp/slices"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion e
Submodule e updated from e5a5a0 to c51383
1 change: 0 additions & 1 deletion e_imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ import (
_ "github.com/vulcand/predicate"
_ "golang.org/x/crypto/bcrypt"
_ "golang.org/x/exp/maps"
_ "golang.org/x/exp/slices"
_ "golang.org/x/mod/semver"
_ "golang.org/x/net/html"
_ "golang.org/x/oauth2"
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamoathenamigration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"io"
"os"
"path"
"slices"
"sort"
"sync"
"time"
Expand All @@ -44,7 +45,6 @@ import (
"github.com/gravitational/trace"
log "github.com/sirupsen/logrus"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"golang.org/x/sync/errgroup"

apievents "github.com/gravitational/teleport/api/types/events"
Expand Down
2 changes: 1 addition & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"reflect"
"regexp"
"runtime/pprof"
"slices"
"strconv"
"strings"
"sync"
Expand All @@ -55,7 +56,6 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
Expand Down
2 changes: 1 addition & 1 deletion integrations/access/servicenow/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"context"
"fmt"
"net/url"
"slices"
"strings"
"time"

"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"golang.org/x/exp/slices"

tp "github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/accessrequest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ package controller

import (
"context"
"slices"
"testing"
"time"

"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Loading

0 comments on commit 44a6bb1

Please sign in to comment.