diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3afbfa8072..0c10c983ef 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -44,5 +44,5 @@ jobs: # check-latest: true - uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.61.0 working-directory: . diff --git a/flypg/cmd.go b/flypg/cmd.go index c9f9444742..d235ff32fd 100644 --- a/flypg/cmd.go +++ b/flypg/cmd.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/json" + "errors" "fmt" fly "github.com/superfly/fly-go" @@ -73,7 +74,7 @@ func (pc *Command) UpdateSettings(ctx context.Context, leaderIp string, config m } if !result.Success { - return fmt.Errorf(result.Message) + return errors.New(result.Message) } return nil @@ -94,7 +95,7 @@ func (pc *Command) UnregisterMember(ctx context.Context, leaderIP string, standb } if !result.Success { - return fmt.Errorf(result.Message) + return errors.New(result.Message) } return nil diff --git a/internal/appconfig/from_machine_set.go b/internal/appconfig/from_machine_set.go index a5ac1942c7..bc18f4c500 100644 --- a/internal/appconfig/from_machine_set.go +++ b/internal/appconfig/from_machine_set.go @@ -209,12 +209,12 @@ func processGroupsFromMachineSet(ctx context.Context, ms machine.MachineSet) (*p for _, cmd := range report.others { otherCmds += fmt.Sprintf(" %s\n", cmd) } - warningMsg += warning("processes", fmt.Sprintf(`Found these additional commands on some machines. Consider adding process groups to your fly.toml and run machines with those process groups. + warningMsg += warning("processes", `Found these additional commands on some machines. Consider adding process groups to your fly.toml and run machines with those process groups. For more info please see: https://fly.io/docs/reference/configuration/#the-processes-section Machine IDs that were not saved to fly.toml: %s Commands they are running: %s -`, strings.Join(otherMachineIds, ", "), otherCmds)) +`, strings.Join(otherMachineIds, ", "), otherCmds) warningMsg += "\n" } diff --git a/internal/command/deploy/machines.go b/internal/command/deploy/machines.go index 650b4c8e24..8dca79ee72 100644 --- a/internal/command/deploy/machines.go +++ b/internal/command/deploy/machines.go @@ -174,7 +174,7 @@ func NewMachineDeployment(ctx context.Context, args MachineDeploymentArgs) (_ Ma // TODO: Blend extraInfo into ValidationError and remove this hack if err, extraInfo := appConfig.ValidateGroups(ctx, lo.Keys(args.ProcessGroups)); err != nil { - fmt.Fprintf(io.ErrOut, extraInfo) + fmt.Fprint(io.ErrOut, extraInfo) tracing.RecordError(span, err, "failed to validate process groups") return nil, err } diff --git a/internal/command/doctor/diag/diag.go b/internal/command/doctor/diag/diag.go index f53712078a..be8887565a 100644 --- a/internal/command/doctor/diag/diag.go +++ b/internal/command/doctor/diag/diag.go @@ -96,12 +96,12 @@ add the --force flag to send us best-effort diagnostics.`) if err = ft.fn(ctx, zip); err != nil { if ft.expect { - fmt.Printf(color.Red(fmt.Sprintf("FAILED: %s\n", err))) + fmt.Print(color.Red(fmt.Sprintf("FAILED: %s\n", err))) } else { - fmt.Printf("skipping\n") + fmt.Print("skipping\n") } } else { - fmt.Printf(color.Green("ok\n")) + fmt.Print(color.Green("ok\n")) } } diff --git a/internal/command/launch/deploy.go b/internal/command/launch/deploy.go index a232913819..f7c2e20dec 100644 --- a/internal/command/launch/deploy.go +++ b/internal/command/launch/deploy.go @@ -74,7 +74,7 @@ func (state *launchState) firstDeploy(ctx context.Context) error { err, extraInfo := state.appConfig.Validate(ctx) if extraInfo != "" { - fmt.Fprintf(io.ErrOut, extraInfo) + fmt.Fprint(io.ErrOut, extraInfo) } if err != nil { return fmt.Errorf("invalid configuration file: %w", err) diff --git a/internal/command/launch/sourceinfo.go b/internal/command/launch/sourceinfo.go index 798aff776f..7679cbdbc7 100644 --- a/internal/command/launch/sourceinfo.go +++ b/internal/command/launch/sourceinfo.go @@ -91,7 +91,7 @@ func determineSourceInfo(ctx context.Context, appConfig *appconfig.Config, copyC if srcInfo.Builder != "" { fmt.Fprintln(io.Out, "Using the following build configuration:") fmt.Fprintln(io.Out, "\tBuilder:", srcInfo.Builder) - if srcInfo.Buildpacks != nil && len(srcInfo.Buildpacks) > 0 { + if len(srcInfo.Buildpacks) > 0 { fmt.Fprintln(io.Out, "\tBuildpacks:", strings.Join(srcInfo.Buildpacks, " ")) } diff --git a/internal/command/postgres/create.go b/internal/command/postgres/create.go index 498c98a78f..b8f25998a1 100644 --- a/internal/command/postgres/create.go +++ b/internal/command/postgres/create.go @@ -152,7 +152,7 @@ func run(ctx context.Context) (err error) { // Initial cluster size may not be greater than 1 with fork-from if pgConfig.InitialClusterSize > 1 { - fmt.Fprintf(io.Out, colorize.Yellow("Warning: --initial-cluster-size is ignored when specifying --fork-from\n")) + fmt.Fprint(io.Out, colorize.Yellow("Warning: --initial-cluster-size is ignored when specifying --fork-from\n")) pgConfig.InitialClusterSize = 1 } diff --git a/internal/command/postgres/failover.go b/internal/command/postgres/failover.go index b6a0b37a72..6555372d53 100644 --- a/internal/command/postgres/failover.go +++ b/internal/command/postgres/failover.go @@ -2,6 +2,7 @@ package postgres import ( "context" + "errors" "fmt" "strings" "time" @@ -399,7 +400,7 @@ func pickNewLeader(ctx context.Context, app *fly.AppCompact, primaryCandidates [ err += "\nplease fix one or more of the above issues, and try again\n" - return nil, fmt.Errorf(err) + return nil, errors.New(err) } // Before doing anything that might mess up, it's useful to check if a dry run of the failover command will work, since that allows repmgr to do some checks diff --git a/internal/command/postgres/restart.go b/internal/command/postgres/restart.go index fb07cfa12a..5ce65f8ed1 100644 --- a/internal/command/postgres/restart.go +++ b/internal/command/postgres/restart.go @@ -136,7 +136,7 @@ func machinesRestart(ctx context.Context, appName string, input *fly.RestartMach if err := pgclient.Failover(ctx); err != nil { msg := fmt.Sprintf("failed to perform failover: %s", err.Error()) if !force { - return fmt.Errorf(msg) + return fmt.Errorf("failed to perform failover: %w", err) } fmt.Fprintln(io.Out, colorize.Red(msg)) diff --git a/internal/command/ssh/sftp.go b/internal/command/ssh/sftp.go index d5e61fe874..04ec9fa1ec 100644 --- a/internal/command/ssh/sftp.go +++ b/internal/command/ssh/sftp.go @@ -144,7 +144,7 @@ func runLs(ctx context.Context) error { return err } - fmt.Printf(walker.Path() + "\n") + fmt.Println(walker.Path()) } return nil diff --git a/internal/command/ssh/ssh_terminal.go b/internal/command/ssh/ssh_terminal.go index f906f6700f..551cdc95da 100644 --- a/internal/command/ssh/ssh_terminal.go +++ b/internal/command/ssh/ssh_terminal.go @@ -56,7 +56,7 @@ func RunSSHCommand(ctx context.Context, app *fly.AppCompact, dialer agent.Dialer } if len(errBuf.Bytes()) > 0 { - return nil, fmt.Errorf(errBuf.String()) + return nil, errors.New(errBuf.String()) } return outBuf.Bytes(), nil diff --git a/internal/machine/config.go b/internal/machine/config.go index 27928c22b5..d1b7c89006 100644 --- a/internal/machine/config.go +++ b/internal/machine/config.go @@ -32,7 +32,7 @@ func ConfirmConfigChanges(ctx context.Context, machine *fly.Machine, targetConfi } if customPrompt != "" { - fmt.Fprintf(io.Out, customPrompt) + fmt.Fprint(io.Out, customPrompt) } else { fmt.Fprintf(io.Out, "Configuration changes to be applied to machine: %s (%s)\n", colorize.Bold(machine.ID), colorize.Bold(machine.Name)) } diff --git a/internal/metrics/db.go b/internal/metrics/db.go index 1db598c623..ed672fe366 100644 --- a/internal/metrics/db.go +++ b/internal/metrics/db.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "io" "net/http" "os" "os/exec" @@ -54,7 +53,7 @@ func FlushMetrics(ctx context.Context) error { } go func() { - io.WriteString(stdin, string(json)) + stdin.Write(json) stdin.Close() }() diff --git a/internal/statuslogger/interactivelogger.go b/internal/statuslogger/interactivelogger.go index 395c6ecbf8..cc14d40cf8 100644 --- a/internal/statuslogger/interactivelogger.go +++ b/internal/statuslogger/interactivelogger.go @@ -50,7 +50,7 @@ func (il *interactiveLogger) Destroy(clear bool) { il.done = false if clear { - fmt.Fprintf(il.io.Out, il.clearStr()) + fmt.Print(il.io.Out, il.clearStr()) } else { fmt.Fprintf(il.io.Out, "%s%s\n", aec.Down(uint(il.height(il.prevLines))), divider) }