Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade golangci-lint #4014

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ jobs:
# check-latest: true
- uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.61.0
working-directory: .
5 changes: 3 additions & 2 deletions flypg/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"

fly "github.com/superfly/fly-go"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/appconfig/from_machine_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion internal/command/deploy/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions internal/command/doctor/diag/diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
dangra marked this conversation as resolved.
Show resolved Hide resolved
} else {
fmt.Printf("skipping\n")
fmt.Print("skipping\n")
}
} else {
fmt.Printf(color.Green("ok\n"))
fmt.Print(color.Green("ok\n"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/command/launch/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/command/launch/sourceinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, " "))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/command/postgres/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion internal/command/postgres/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package postgres

import (
"context"
"errors"
"fmt"
"strings"
"time"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/command/postgres/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion internal/command/ssh/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func runLs(ctx context.Context) error {
return err
}

fmt.Printf(walker.Path() + "\n")
fmt.Println(walker.Path())
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/command/ssh/ssh_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/machine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
3 changes: 1 addition & 2 deletions internal/metrics/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"os/exec"
Expand Down Expand Up @@ -54,7 +53,7 @@ func FlushMetrics(ctx context.Context) error {
}

go func() {
io.WriteString(stdin, string(json))
stdin.Write(json)
stdin.Close()
}()

Expand Down
2 changes: 1 addition & 1 deletion internal/statuslogger/interactivelogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading