Code Monkey home page Code Monkey logo

Comments (2)

ghemawat avatar ghemawat commented on July 18, 2024 1

Hi Daniel,

We would love to take you up on your offer to help enable errcheck.

Your suggestion on just focusing on non-test code for now seems spot on.

_, _ = w.Write(...)
// or
w.Write(...) //nolint:errcheck

I think I would prefer the latter since it will be easier to spot and search for. So let's go with the //nolint:errcheck approach.

Thanks for offering to help and your clear write-up of the types of changes that would be needed.

from weaver.

dnephin avatar dnephin commented on July 18, 2024

Initially I'd want to enable it only for production code (not tests), to limit the number of changes required to get it enabled. Something like this:

issues:
  exclude-rules:
    - path: '_test\.go'
      linters: [errcheck]

I think a bunch of the unhandled errors are safe to ignore (ex: writing an HTTP response from a handler). Those can be ignored with either:

_, _ = w.Write(...)
// or
w.Write(...) //nolint:errcheck

Do you have a preference on one of those styles?


There are a few cases where it seems like the error simply needs to be returned:

formatConst(w, e.GetConstExpr())
return nil

bs.run()
return nil

conn.updateEndpoints(endpoints)

or logged:

terminateDeployment(locs, dep)

indexTemplate.Execute(w, content)

rc.updateEndpoints(endpoints)

A log here to inform the user that the port is in use would probably help avoid confusion when perfetto isn't able to display the trace.

lis, err := net.Listen("tcp", "localhost:9001")


The remaining cases of unhandled errors seems to be mostly in these two categories:

  1. starting goroutines with a function that returns an error - in a few of these cases the only possible return value is ctx.Err. I wonder if the error return value could be removed from the function signature in those cases.
  2. sending an RPC response from an RPC handler when the operation is performed in a goroutine. In these cases I expect the error is also safe to ignore because the client receives the error response, and the caller doesn't care about it.

from weaver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.