Hacker News new | ask | show | jobs
by agnivade 2687 days ago
> I found it too easy to accidentally forget to check an error

Use https://github.com/kisielk/errcheck for that.

Or prefer https://staticcheck.io/ for a larger set of checks.

1 comments

    fmt.Println("foo")
I don't see errcheck complaining there

how about (taken from here: (https://www.reddit.com/r/programming/comments/ak305l/goodbye...):

    r1, err := fn1()
    r2, err = fn2()
    if err != nil {
      return err
    }
err check doesn't complain either
That second example is really surprising. This sort of thing happens all the time in production when lines get moved around. Does anyone know why errcheck misses it?
Not sure about that. But https://github.com/gordonklaus/ineffassign catches that.