Skip to content

Commit 9032428

Browse files
committed
fix linter warnings
1 parent 26087e8 commit 9032428

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

internal/config/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ func eachOption(g *flags.Group, f func(*flags.Group, *flags.Option)) {
5353
// VisitAll will execute fn() for all options found in command line.
5454
// Since we have only two level of nesting it's enough to use simplified group-prefixed name.
5555
func (cmdSet cmdArgSet) VisitAll(fn func(viper.FlagValue)) {
56-
root := cmdSet.Parser.Group.Find("Application Options")
56+
root := cmdSet.Group.Find("Application Options")
5757
eachOption(root, func(g *flags.Group, o *flags.Option) {
5858
name := o.LongName
5959
if g != root {
60-
name = g.ShortDescription + cmdSet.Parser.NamespaceDelimiter + name
60+
name = g.ShortDescription + cmdSet.NamespaceDelimiter + name
6161
}
6262
fn(cmdArg{name, o})
6363
})
6464
}
6565

6666
func (cmdSet cmdArgSet) setDefaults(v *viper.Viper) {
67-
eachOption(cmdSet.Parser.Group, func(g *flags.Group, o *flags.Option) {
67+
eachOption(cmdSet.Group, func(g *flags.Group, o *flags.Option) {
6868
if o.Default != nil && o.IsSetDefault() {
6969
name := o.LongName
70-
if g != cmdSet.Parser.Group {
71-
name = g.ShortDescription + cmdSet.Parser.NamespaceDelimiter + name
70+
if g != cmdSet.Group {
71+
name = g.ShortDescription + cmdSet.NamespaceDelimiter + name
7272
}
7373
v.SetDefault(name, o.Value())
7474
}
@@ -91,12 +91,12 @@ func NewConfig(writer io.Writer) (*CmdOptions, error) {
9191
v.SetConfigFile(v.GetString("config"))
9292
err := v.ReadInConfig() // Find and read the config file
9393
if err != nil { // Handle errors reading the config file
94-
return nil, fmt.Errorf("Fatal error reading config file: %w", err)
94+
return nil, fmt.Errorf("fatal error reading config file: %w", err)
9595
}
9696
}
9797
conf := &CmdOptions{}
9898
if err = v.Unmarshal(conf); err != nil {
99-
return nil, fmt.Errorf("Fatal error unmarshalling config file: %w", err)
99+
return nil, fmt.Errorf("fatal error unmarshalling config file: %w", err)
100100
}
101101
if conf.ClientName == "" {
102102
buf := bytes.NewBufferString("The required flag `-c, --clientname` was not specified\n")

internal/pgengine/bootstrap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func NewDB(DB PgxPoolIface, args ...string) *PgEngine {
135135
}
136136

137137
func quoteIdent(s string) string {
138-
return `"` + strings.Replace(s, `"`, `""`, -1) + `"`
138+
return `"` + strings.ReplaceAll(s, `"`, `""`) + `"`
139139
}
140140

141141
// getPgxConnConfig transforms standard connestion string to pgx specific one with
@@ -230,7 +230,7 @@ func (pge *PgEngine) TryLockClientName(ctx context.Context, conn QueryRowIface)
230230
if e := conn.QueryRow(ctx, sql, pge.Getsid(), pge.ClientName).Scan(&locked); e != nil {
231231
return e
232232
} else if !locked {
233-
return errors.New("Cannot obtain lock for a session")
233+
return errors.New("cannot obtain lock for a session")
234234
}
235235
return nil
236236
}
@@ -240,12 +240,12 @@ func (pge *PgEngine) ExecuteCustomScripts(ctx context.Context, filename ...strin
240240
for _, f := range filename {
241241
sql, err := os.ReadFile(f)
242242
if err != nil {
243-
pge.l.WithError(err).Error("Cannot read command file")
243+
pge.l.WithError(err).Error("cannot read command file")
244244
return err
245245
}
246246
pge.l.Info("Executing script: ", f)
247247
if _, err = pge.ConfigDb.Exec(ctx, string(sql)); err != nil {
248-
pge.l.WithError(err).Error("Script execution failed")
248+
pge.l.WithError(err).Error("script execution failed")
249249
return err
250250
}
251251
pge.l.Info("Script file executed: ", f)

internal/pgengine/notification.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ func (pge *PgEngine) NotificationHandler(c *pgconn.PgConn, n *pgconn.Notificatio
6363
pge.chainSignalChan <- signal
6464
return
6565
}
66-
err = fmt.Errorf("Unknown chain ID: %d", signal.ConfigID)
66+
err = fmt.Errorf("unknown chain ID: %d", signal.ConfigID)
6767
default:
68-
err = fmt.Errorf("Unknown command: %s", signal.Command)
68+
err = fmt.Errorf("unknown command: %s", signal.Command)
6969
}
7070
}
71-
l.WithError(err).Error("Syntax error in payload")
71+
l.WithError(err).Error("syntax error in payload")
7272
}
7373

7474
// WaitForChainSignal returns configuration id from the notifications

internal/scheduler/chain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (sch *Scheduler) processAsyncChain(ctx context.Context, chainSignal ChainSi
6262
case "START":
6363
var c Chain
6464
if err := sch.pgengine.SelectChain(ctx, &c, chainSignal.ConfigID); err != nil {
65-
return fmt.Errorf("Cannot start chain with ID: %d; %w", chainSignal.ConfigID, err)
65+
return fmt.Errorf("cannot start chain with ID: %d; %w", chainSignal.ConfigID, err)
6666
}
6767
go func() {
6868
select {
@@ -77,7 +77,7 @@ func (sch *Scheduler) processAsyncChain(ctx context.Context, chainSignal ChainSi
7777
cancel()
7878
return nil
7979
}
80-
return fmt.Errorf("Cannot stop chain with ID: %d. No running chain found", chainSignal.ConfigID)
80+
return fmt.Errorf("cannot stop chain with ID: %d. No running chain found", chainSignal.ConfigID)
8181
}
8282
return nil
8383
}

internal/scheduler/shell.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (sch *Scheduler) ExecuteProgramCommand(ctx context.Context, command string,
3030

3131
command = strings.TrimSpace(command)
3232
if command == "" {
33-
return -1, "", errors.New("Program command cannot be empty")
33+
return -1, "", errors.New("program command cannot be empty")
3434
}
3535
if len(paramValues) == 0 { //mimic empty param
3636
paramValues = []string{""}
@@ -50,7 +50,7 @@ func (sch *Scheduler) ExecuteProgramCommand(ctx context.Context, command string,
5050
if err != nil {
5151
//check if we're dealing with an ExitError - i.e. return code other than 0
5252
if exitError, ok := err.(*exec.ExitError); ok {
53-
exitCode := exitError.ProcessState.ExitCode()
53+
exitCode := exitError.ExitCode()
5454
l.WithField("retcode", exitCode).Debug("Program run", cmdLine, exitCode)
5555
return exitCode, stdout, exitError
5656
}

internal/scheduler/tasks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func taskDownload(ctx context.Context, _ *Scheduler, paramValues string) (stdout
117117
return "", err
118118
}
119119
if len(opts.FileUrls) == 0 {
120-
return "", errors.New("Files to download are not specified")
120+
return "", errors.New("files to download are not specified")
121121
}
122122
return tasks.DownloadUrls(ctx, opts.FileUrls, opts.DestPath, opts.WorkersNum)
123123
}

0 commit comments

Comments
 (0)