Skip to content

Commit c5c30e2

Browse files
committed
golangli-lint fixes
1 parent e566f9b commit c5c30e2

37 files changed

Lines changed: 79 additions & 64 deletions

cmd/event_handler/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ func main() {
1919
details := flag.String("details", "", "details")
2020
flag.Parse()
2121

22-
succ := true
23-
if *success == "0" {
24-
succ = false
25-
}
22+
succ := *success != "0"
2623

2724
req := api.EventRequest{
2825
Name: *event,

cmd/flexctl/backups.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var backupShowCmd = &cobra.Command{
5757
if !backupsEnabled() {
5858
return fmt.Errorf("backups are not enabled")
5959
}
60+
6061
return showBackup(cmd, args)
6162
},
6263
Args: cobra.ExactArgs(1),
@@ -172,6 +173,7 @@ func listBackups(cmd *cobra.Command) error {
172173
}
173174

174175
fmt.Println(string(jsonBytes))
176+
175177
return nil
176178
}
177179

@@ -229,7 +231,7 @@ func backupsEnabled() bool {
229231
}
230232

231233
func newBackupConfig() *cobra.Command {
232-
var cmd = &cobra.Command{
234+
cmd := &cobra.Command{
233235
Use: "config",
234236
Short: "Manage backup configuration",
235237
}
@@ -248,6 +250,7 @@ func getAppName() (string, error) {
248250
if name == "" {
249251
return "", fmt.Errorf("FLY_APP_NAME is not set")
250252
}
253+
251254
return name, nil
252255
}
253256

@@ -257,11 +260,12 @@ func getApiUrl() (string, error) {
257260
return "", err
258261
}
259262
url := fmt.Sprintf("http://%s.internal:5500", hostname)
263+
260264
return url, nil
261265
}
262266

263267
func newConfigShow() *cobra.Command {
264-
var cmd = &cobra.Command{
268+
cmd := &cobra.Command{
265269
Use: "show",
266270
Short: "Show current configuration",
267271
RunE: func(cmd *cobra.Command, args []string) error {
@@ -308,7 +312,7 @@ type configUpdateResult struct {
308312
}
309313

310314
func newConfigUpdate() *cobra.Command {
311-
var cmd = &cobra.Command{
315+
cmd := &cobra.Command{
312316
Use: "update",
313317
Short: "Update configuration",
314318
}

cmd/flexctl/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
)
99

1010
func main() {
11-
var rootCmd = &cobra.Command{
11+
rootCmd := &cobra.Command{
1212
Use: "flexctl",
1313
SilenceErrors: true,
1414
SilenceUsage: true,
1515
}
1616

1717
// Backup commands
18-
var backupCmd = &cobra.Command{Use: "backup"}
18+
backupCmd := &cobra.Command{Use: "backup"}
1919
backupCmd.Aliases = []string{"backups"}
2020

2121
rootCmd.AddCommand(backupCmd)

cmd/monitor/monitor_backup_retention.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
)
1010

1111
func monitorBackupRetention(ctx context.Context, node *flypg.Node, barman *flypg.Barman) {
12-
1312
ticker := time.NewTicker(defaultBackupRetentionEvalFrequency)
1413
defer ticker.Stop()
1514

cmd/monitor/monitor_backup_schedule.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func calculateNextBackupTime(barman *flypg.Barman, lastBackupTime time.Time) tim
111111
if lastBackupTime.IsZero() {
112112
return -1
113113
}
114+
114115
return time.Until(lastBackupTime.Add(backupFrequency(barman)))
115116
}
116117

cmd/monitor/monitor_backup_schedule_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func TestCalculateNextBackupTime(t *testing.T) {
115115
t.Fatalf("expected next backup time duration to be %f, but got %f", expected, val)
116116
}
117117
})
118-
119118
}
120119

121120
func setDefaultEnv(t *testing.T) {
@@ -129,13 +128,14 @@ func setup(t *testing.T) error {
129128

130129
if _, err := os.Stat(pgTestDirectory); err != nil {
131130
if os.IsNotExist(err) {
132-
if err := os.Mkdir(pgTestDirectory, 0750); err != nil {
131+
if err := os.Mkdir(pgTestDirectory, 0o750); err != nil {
133132
return err
134133
}
135134
} else {
136135
return err
137136
}
138137
}
138+
139139
return nil
140140
}
141141

cmd/monitor/monitor_cluster_state.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func clusterStateMonitorTick(ctx context.Context, node *flypg.Node) error {
4242
if err := flypg.Quarantine(ctx, node, primary); err != nil {
4343
return fmt.Errorf("failed to quarantine failed primary: %s", err)
4444
}
45+
4546
return fmt.Errorf("primary has been quarantined: %s", err)
4647
} else if err != nil {
4748
return fmt.Errorf("failed to run zombie diagnosis: %s", err)

cmd/monitor/monitor_replication_slots.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func replicationSlotMonitorTick(ctx context.Context, node *flypg.Node, inactiveS
7474
}
7575

7676
delete(inactiveSlotStatus, int(slot.MemberID))
77+
7778
continue
7879
}
7980

cmd/pg_unregister/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ func removeReplicationSlot(ctx context.Context, conn *pgx.Conn, slotName string)
107107
if err == pgx.ErrNoRows {
108108
return nil
109109
}
110+
110111
return fmt.Errorf("failed to get replication slot %s: %v", slotName, err)
111112
}
112113

cmd/start/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func main() {
7676
fmt.Printf("failed post-init: %s. Retrying...\n", err)
7777
continue
7878
}
79+
7980
return
8081
}
8182
}()
@@ -159,6 +160,7 @@ func scaleToZeroWorker(ctx context.Context, node *flypg.Node) error {
159160
if current > 1 {
160161
continue
161162
}
163+
162164
return fmt.Errorf("scale to zero condition hit")
163165
}
164166
}
@@ -176,6 +178,7 @@ func getCurrentConnCount(ctx context.Context, node *flypg.Node) (int, error) {
176178
if err := conn.QueryRow(ctx, sql).Scan(&current); err != nil {
177179
return 0, err
178180
}
181+
179182
return current, nil
180183
}
181184

0 commit comments

Comments
 (0)