Skip to content

Commit

Permalink
Replace golang.org/x/exp/slices with slices in the stdlib (#2767)
Browse files Browse the repository at this point in the history
* Replace golang.org/x/exp/slices with slices in the stdlib

* Upgrade golang.org/x/exp

* Tidy
  • Loading branch information
michaeldwan authored Aug 30, 2023
1 parent 0808056 commit 979dd7f
Show file tree
Hide file tree
Showing 30 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"net/http"
"os"
"regexp"
"slices"
"strings"
"time"

genq "github.com/Khan/genqlient/graphql"
"github.com/superfly/graphql"
"golang.org/x/exp/slices"
)

var (
Expand Down
1 change: 0 additions & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/PuerkitoBio/rehttp v1.2.0
github.com/superfly/graphql v0.2.4
golang.org/x/crypto v0.12.0
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
)

require (
Expand Down
2 changes: 0 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUO
github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
Expand Down
2 changes: 1 addition & 1 deletion cmd/audit/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"encoding/json"
"fmt"
"os"
"slices"
"strings"
"unicode"

"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/superfly/flyctl/internal/command/root"
"golang.org/x/exp/slices"
)

func newLintCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cmd/audit/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package main

import (
"os"
"slices"
"strconv"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/superfly/flyctl/internal/command/root"
"golang.org/x/exp/slices"
)

func formatRawText(desc string) string {
Expand Down
2 changes: 1 addition & 1 deletion flaps/flaps_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"
"net/http"
"slices"

"github.com/samber/lo"
"github.com/superfly/flyctl/api"
"golang.org/x/exp/slices"
)

var destroyedVolumeStates = []string{"scheduling_destroy", "fork_cleanup", "waiting_for_detach", "pending_destroy", "destroying"}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ require (
github.com/vektah/gqlparser v1.3.1
github.com/vektah/gqlparser/v2 v2.5.6
golang.org/x/crypto v0.12.0
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/net v0.14.0
golang.org/x/sync v0.3.0
golang.org/x/term v0.11.0
Expand Down Expand Up @@ -150,7 +150,7 @@ require (
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.opentelemetry.io/otel/metric v0.37.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/tools v0.9.3 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -1059,8 +1059,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=
golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E=
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion internal/appconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"net/url"
"os"
"reflect"
"slices"

"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/internal/machine"
"github.com/superfly/flyctl/scanner"
"golang.org/x/exp/slices"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/appconfig/processgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package appconfig

import (
"fmt"
"slices"
"strings"

"github.com/google/shlex"
"github.com/samber/lo"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/helpers"
"golang.org/x/exp/slices"
)

// ProcessNames lists each key of c.Processes, sorted lexicographically
Expand Down
2 changes: 1 addition & 1 deletion internal/appconfig/toplevelcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package appconfig

import (
"fmt"
"slices"
"strings"

"github.com/samber/lo"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/internal/sentry"
"golang.org/x/exp/slices"
)

type ToplevelCheck struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/appconfig/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"
"time"

Expand All @@ -12,7 +13,6 @@ import (
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/sentry"
"golang.org/x/exp/slices"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/command/deploy/machines_deploymachinesapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math"
"net"
"slices"
"strconv"
"strings"
"time"
Expand All @@ -18,7 +19,6 @@ import (
"github.com/superfly/flyctl/internal/machine"
"github.com/superfly/flyctl/terminal"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

type ProcessGroupsDiff struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/extensions/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"path/filepath"
"slices"
"time"

"github.com/briandowns/spinner"
Expand All @@ -16,7 +17,6 @@ import (
"github.com/superfly/flyctl/internal/prompt"
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/scanner"
"golang.org/x/exp/slices"
)

type Extension struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/launch/legacy/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"path/filepath"
"slices"
"strings"

"github.com/logrusorgru/aurora"
Expand All @@ -21,7 +22,6 @@ import (
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/scanner"
"github.com/superfly/graphql"
"golang.org/x/exp/slices"
)

func Run(ctx context.Context) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/machine/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package machine
import (
"context"
"fmt"
"slices"
"strings"
"time"

Expand All @@ -20,7 +21,6 @@ import (
"github.com/superfly/flyctl/internal/watch"
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/terminal"
"golang.org/x/exp/slices"
)

func newClone() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/machine/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strconv"
"strings"
"time"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/pkg/errors"
"github.com/samber/lo"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/flaps"
Expand Down
8 changes: 5 additions & 3 deletions internal/command/migrate_to_v2/migrate_to_v2.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package migrate_to_v2

import (
"cmp"
"context"
"errors"
"fmt"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -32,7 +34,6 @@ import (
"github.com/superfly/flyctl/iostreams"
"github.com/superfly/flyctl/terminal"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

const defaultWaitTimeout = 5 * time.Minute
Expand Down Expand Up @@ -283,9 +284,10 @@ func NewV2PlatformMigrator(ctx context.Context, appName string) (V2PlatformMigra
}

// sort allocs by version descending
slices.SortFunc(allocs, func(i, j *api.AllocationStatus) bool {
return i.Version > j.Version
slices.SortFunc(allocs, func(i, j *api.AllocationStatus) int {
return cmp.Compare(i.Version, j.Version)
})
slices.Reverse(allocs)

var highestVersion int
allocs = lo.Filter(allocs, func(alloc *api.AllocationStatus, _ int) bool {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/migrate_to_v2/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package migrate_to_v2
import (
"context"
"fmt"
"slices"
"strings"

"github.com/samber/lo"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/internal/appconfig"
"golang.org/x/exp/slices"
)

func (m *v2PlatformMigrator) validateVolumes(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/regions/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package regions
import (
"context"
"fmt"
"slices"

"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/appconfig"
"github.com/superfly/flyctl/internal/config"
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/internal/render"
"github.com/superfly/flyctl/iostreams"
"golang.org/x/exp/slices"

"github.com/superfly/flyctl/api"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/command/scale/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scale
import (
"context"
"fmt"
"slices"
"strconv"
"strings"

Expand All @@ -14,7 +15,6 @@ import (
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/iostreams"
"golang.org/x/exp/slices"
)

func newScaleCount() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/scale/show_machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"slices"
"strings"

"github.com/samber/lo"
Expand All @@ -13,7 +14,6 @@ import (
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/internal/render"
"github.com/superfly/flyctl/iostreams"
"golang.org/x/exp/slices"
)

func runMachinesScaleShow(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/status/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"slices"
"sort"
"strconv"
"strings"
Expand All @@ -15,7 +16,6 @@ import (
"github.com/superfly/flyctl/internal/config"
"github.com/superfly/flyctl/internal/render"
"github.com/superfly/flyctl/iostreams"
"golang.org/x/exp/slices"
)

func getFromMetadata(m *api.Machine, key string) string {
Expand Down
2 changes: 1 addition & 1 deletion internal/flag/completion/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package completion
import (
"context"
"fmt"
"slices"
"strings"

"github.com/samber/lo"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/client"
"github.com/superfly/flyctl/internal/flag/flagnames"
"golang.org/x/exp/slices"
)

func CompleteApps(
Expand Down
2 changes: 1 addition & 1 deletion internal/flag/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package flag

import (
"context"
"slices"
"time"

"github.com/spf13/pflag"
"github.com/superfly/flyctl/internal/env"
"github.com/superfly/flyctl/internal/flag/flagctx"
"github.com/superfly/flyctl/internal/flag/flagnames"
"golang.org/x/exp/slices"
)

// NewContext derives a context that carries fs from ctx.
Expand Down
Loading

0 comments on commit 979dd7f

Please sign in to comment.