diff options
author | Moritz Poldrack <git@moritz.sh> | 2022-07-31 15:15:27 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-04 21:58:04 +0200 |
commit | 70bfcfef42578079f211d87cddc49519ee3503dc (patch) | |
tree | ae35c38e3980c73af2b43be10fe8cc9ece4f3f9a /completer/completer.go | |
parent | 978d35d356e8752bdd272884df48a6289d88b40a (diff) | |
download | aerc-70bfcfef42578079f211d87cddc49519ee3503dc.tar.gz |
lint: work nicely with wrapped errors (errorlint)
Error wrapping as introduced in Go 1.13 adds some additional logic to
use for comparing errors and adding information to it.
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'completer/completer.go')
-rw-r--r-- | completer/completer.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/completer/completer.go b/completer/completer.go index c5624f9d..202607a9 100644 --- a/completer/completer.go +++ b/completer/completer.go @@ -2,6 +2,7 @@ package completer import ( "bufio" + "errors" "fmt" "io" "io/ioutil" @@ -82,14 +83,14 @@ func (c *Completer) completeAddress(s string) ([]string, string, error) { } stdout, err := cmd.StdoutPipe() if err != nil { - return nil, "", fmt.Errorf("stdout: %v", err) + return nil, "", fmt.Errorf("stdout: %w", err) } stderr, err := cmd.StderrPipe() if err != nil { - return nil, "", fmt.Errorf("stderr: %v", err) + return nil, "", fmt.Errorf("stderr: %w", err) } if err := cmd.Start(); err != nil { - return nil, "", fmt.Errorf("cmd start: %v", err) + return nil, "", fmt.Errorf("cmd start: %w", err) } // Wait returns an error if the exit status != 0, which some completion // programs will do to signal no matches. We don't want to spam the user with @@ -104,7 +105,7 @@ func (c *Completer) completeAddress(s string) ([]string, string, error) { if msg != "" { msg = ": " + msg } - return nil, "", fmt.Errorf("read completions%s: %v", msg, err) + return nil, "", fmt.Errorf("read completions%s: %w", msg, err) } return completions, prefix, nil @@ -150,7 +151,7 @@ func readCompletions(r io.Reader) ([]string, error) { completions := []string{} for { line, err := buf.ReadString('\n') - if err == io.EOF { + if errors.Is(err, io.EOF) { return completions, nil } else if err != nil { return nil, err |