Skip to content

Commit

Permalink
refactor: bye golang.org/x/exp
Browse files Browse the repository at this point in the history
After Go 1.23, the standard library provides what we use from
the exp package.
  • Loading branch information
kzys committed Sep 17, 2024
1 parent 76d027c commit 49ede20
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 23 deletions.
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/superfly/flyctl

go 1.22.0

toolchain go1.22.6
go 1.23.1

require (
github.com/AlecAivazis/survey/v2 v2.3.7
Expand Down Expand Up @@ -84,7 +82,6 @@ require (
go.opentelemetry.io/otel/sdk v1.30.0
go.opentelemetry.io/otel/trace v1.30.0
golang.org/x/crypto v0.27.0
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/mod v0.21.0
golang.org/x/net v0.29.0
golang.org/x/sync v0.8.0
Expand Down Expand Up @@ -254,6 +251,7 @@ require (
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/tools v0.24.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion internal/command/command_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strconv"
"strings"

Expand All @@ -17,7 +18,6 @@ import (
"github.com/samber/lo"
fly "github.com/superfly/fly-go"
"github.com/superfly/flyctl/iostreams"
"golang.org/x/exp/slices"

"github.com/superfly/flyctl/internal/appconfig"
"github.com/superfly/flyctl/internal/build/imgsrc"
Expand Down
4 changes: 2 additions & 2 deletions internal/command/deploy/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"maps"
"slices"
"strings"
"sync"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/superfly/flyctl/terminal"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/maps"
)

const (
Expand Down Expand Up @@ -404,7 +404,7 @@ func (md *machineDeployment) setMachinesForDeployment(ctx context.Context) error
s = "s"
}

filtersAppliedStr := strings.Join(maps.Keys(filtersApplied), "/")
filtersAppliedStr := strings.Join(slices.Collect(maps.Keys(filtersApplied)), "/")

fmt.Fprintf(md.io.ErrOut, "%s filter%s applied, deploying to %d/%d machines\n", filtersAppliedStr, s, len(machines), nMachines)
}
Expand Down
5 changes: 2 additions & 3 deletions internal/command/deploy/machines_deploymachinesapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"maps"
"math"
"net"
"slices"
Expand All @@ -31,7 +32,6 @@ import (
"github.com/superfly/flyctl/terminal"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/maps"
"golang.org/x/sync/errgroup"
)

Expand Down Expand Up @@ -281,9 +281,8 @@ func (md *machineDeployment) deployCanaryMachines(ctx context.Context) (err erro
func (md *machineDeployment) deployCreateMachinesForGroups(ctx context.Context, processGroupMachineDiff ProcessGroupsDiff) (err error) {
groupsWithAutostopEnabled := make(map[string]bool)
groupsWithAutosuspendEnabled := make(map[string]bool)
groups := maps.Keys(processGroupMachineDiff.groupsNeedingMachines)
groups := slices.Sorted(maps.Keys(processGroupMachineDiff.groupsNeedingMachines))
total := len(groups)
slices.Sort(groups)

sl := statuslogger.Create(ctx, total, true)
defer sl.Destroy(false)
Expand Down
2 changes: 1 addition & 1 deletion internal/command/platform/regions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package platform
import (
"context"
"fmt"
"slices"
"sort"

"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/superfly/flyctl/iostreams"

Expand Down
2 changes: 1 addition & 1 deletion internal/command/redis/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"errors"
"fmt"
"slices"

"github.com/spf13/cobra"
"golang.org/x/exp/slices"

fly "github.com/superfly/fly-go"
"github.com/superfly/flyctl/gql"
Expand Down
4 changes: 2 additions & 2 deletions 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"
"maps"
"slices"
"strconv"
"strings"
Expand All @@ -16,7 +17,6 @@ import (
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/internal/flag/completion"
"github.com/superfly/flyctl/internal/flapsutil"
"golang.org/x/exp/maps"
)

func newScaleCount() *cobra.Command {
Expand Down Expand Up @@ -75,7 +75,7 @@ func runScaleCount(ctx context.Context) error {
return err
}

unknownNames := lo.Filter(maps.Keys(groups), func(x string, _ int) bool {
unknownNames := lo.Filter(slices.Collect(maps.Keys(groups)), func(x string, _ int) bool {
return !slices.Contains(processNames, x)
})
if len(unknownNames) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/version/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"fmt"
"os"
"os/exec"
"slices"
"strings"

"github.com/samber/lo"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/terminal"
"golang.org/x/exp/slices"

"github.com/superfly/flyctl/internal/buildinfo"
"github.com/superfly/flyctl/internal/cache"
Expand Down
4 changes: 2 additions & 2 deletions internal/config/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"maps"
"slices"
"strconv"
"sync"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/superfly/flyctl/internal/task"
"github.com/superfly/macaroon"
"github.com/superfly/macaroon/flyio"
"golang.org/x/exp/maps"
)

// UserURLCallback is a function that opens a URL in the user's browser. This is
Expand Down Expand Up @@ -272,7 +272,7 @@ func doFetchOrgTokens(ctx context.Context, t *tokens.Tokens, fetchOrgs orgFetche
defer wgLock.Unlock()
macToks = append(macToks, m)
}
for _, graphID := range maps.Values(graphIDByNumericID) {
for graphID := range maps.Values(graphIDByNumericID) {
graphID := graphID

wg.Add(1)
Expand Down
2 changes: 1 addition & 1 deletion internal/haikunator/haikunator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"crypto/rand"
"math/big"
rand2 "math/rand"
"slices"
"strconv"
"strings"

"github.com/superfly/flyctl/helpers"
"golang.org/x/exp/slices"
)

var adjectives = strings.Fields(`
Expand Down
5 changes: 3 additions & 2 deletions internal/machine/leasable_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"errors"
"fmt"
"maps"
"net/http"
"slices"
"time"

"github.com/jpillora/backoff"
Expand All @@ -18,7 +20,6 @@ import (
"github.com/superfly/flyctl/terminal"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/maps"
)

type LeasableMachine interface {
Expand Down Expand Up @@ -316,7 +317,7 @@ func (lm *leasableMachine) WaitForHealthchecksToPass(ctx context.Context, timeou
waitCtx, cancel := ctrlc.HookCancelableContext(context.WithTimeout(ctx, timeout))
defer cancel()

checkDefs := maps.Values(lm.Machine().Config.Checks)
checkDefs := slices.Colect(maps.Values(lm.Machine().Config.Checks))

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest-m)

undefined: slices.Colect

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test (macos-latest-xl)

undefined: slices.Colect

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test_build

undefined: slices.Colect

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test (windows-latest-l)

undefined: slices.Colect

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test / test (ubuntu-latest-m, ., test)

undefined: slices.Colect

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test / test (macos-latest-xl, ., test)

undefined: slices.Colect

Check failure on line 320 in internal/machine/leasable_machine.go

View workflow job for this annotation

GitHub Actions / test / test (windows-latest-l, ., test)

undefined: slices.Colect
for _, s := range lm.Machine().Config.Services {
checkDefs = append(checkDefs, s.Checks...)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/machine/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package machine
import (
"context"
"fmt"
"maps"
"slices"
"time"

fly "github.com/superfly/fly-go"
"github.com/superfly/flyctl/internal/flapsutil"
"github.com/superfly/flyctl/internal/watch"
"github.com/superfly/flyctl/iostreams"
"golang.org/x/exp/maps"
)

var cpusPerKind = map[string][]int{
Expand Down
2 changes: 1 addition & 1 deletion internal/set/set_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package set

import (
"slices"
"testing"

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

func TestSet(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package version
import (
"encoding/json"
"math/rand"
"slices"
"testing"
"time"

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

func TestEncode(t *testing.T) {
Expand Down

0 comments on commit 49ede20

Please sign in to comment.