Skip to content

Commit

Permalink
fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Feb 16, 2019
1 parent f4fb867 commit 2455df1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func WithDeadline(deadline time.Time) <-chan struct{} {
return ch
}
go func() {
<-time.After(deadline.Sub(time.Now()))
<-time.After(deadline.Sub(time.Now())) // nolint: gosimple
close(ch)
}()
return ch
Expand Down
22 changes: 8 additions & 14 deletions cmd/retry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,15 @@ type application struct {
// Run executes the application logic.
func (app application) Run() {
var (
result, err = parse(app.Stderr, app.Args[0], app.Args[1:]...)
format = func() string {
if result.Debug {
return "an error occurred: %+v\n"
}
return "an error occurred: %v\n"
}()
result, err = parse(app.Stderr, app.Args[0], app.Args[1:]...)
start, finish time.Time
shutdown, spin = app.Shutdown, spinner.New(spinner.CharSets[17], 100*time.Millisecond)
stderr, stdout = bytes.NewBuffer(nil), bytes.NewBuffer(nil)
report = template.Must(template.New("report").Parse(DefaultReport))
)
if err != nil {
if err != flag.ErrHelp {
color.New(color.FgRed).Fprintf(app.Stderr, format, err)
_, _ = color.New(color.FgRed).Fprintf(app.Stderr, "an error occurred: %v\n", err)
app.Shutdown(failed)
return
}
Expand All @@ -85,9 +79,9 @@ func (app application) Run() {
// TODO try to find or implement by myself
// - https://github.com/variadico/noti
// - https://github.com/jolicode/JoliNotif
color.New(color.FgYellow).Fprintln(stderr, "notify component is not ready yet")
_, _ = color.New(color.FgYellow).Fprintln(stderr, "notify component is not ready yet")
}
report.Execute(app.Stdout, struct {
_ = report.Execute(app.Stdout, struct {
Name string
Error string
Start, End string
Expand All @@ -96,7 +90,7 @@ func (app application) Run() {
Stderr string
}{
Name: command,
Error: fmt.Sprintf(format, err),
Error: fmt.Sprintf("an error occurred: %v\n", err),
Start: start.Format("2006-01-02 15:04:05.99"),
End: finish.Format("2006-01-02 15:04:05.99"),
Elapsed: finish.Sub(start),
Expand All @@ -113,8 +107,9 @@ func (app application) Run() {
spin.Start()
start = time.Now()
} else {
spin.Color("red")
color.New(color.FgYellow).Fprintf(stderr, "#%d attempt at %s... \n", attempt+1, time.Now().Sub(start))
_ = spin.Color("red")
_, _ = color.New(color.FgYellow).Fprintf(stderr, "#%d attempt at %s... \n", attempt+1,
time.Now().Sub(start)) // nolint: gosimple
}
cmd := exec.Command(result.Args[0], result.Args[1:]...)
cmd.Stderr, cmd.Stdout = stderr, stdout
Expand All @@ -129,5 +124,4 @@ func (app application) Run() {
return
}
app.Shutdown(success)
return
}

0 comments on commit 2455df1

Please sign in to comment.