4 ms·
Personally I found it too easy to accidentally forget to check an error, or to shadow a named error return, or to create a nil error that doesn't compare equal
by oconnor663 8y ago
Personally I found it too easy to accidentally forget to check an error, or to shadow a named error return, or to create a nil error that doesn't compare equal to nil. Also to write a method that appears to mutate the receiver but which in fact copies it.
- agnivade 8y ago> I found it too easy to accidentally forget to check an error Use https://github.com/kisielk/errcheck https://github.com/kisielk/errcheck for that. Or prefer https://staticcheck.io/ https://staticcheck.io/ for a larger set of checks.
- apta 8y agofmt.Println("foo") I don't see errcheck complaining there how about (taken from here: (https://www.reddit.com/r/programming/comments/ak305l/goodbye_world_the_perils_of_relying_on_output/ef28swk/ 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
- oconnor663 8y agoThat 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?
- agnivade 8y agoNot sure about that. But https://github.com/gordonklaus/ineffassign https://github.com/gordonklaus/ineffassign catches that.
- spdionis 8y agouse an IDE
- rnvhhynr 8y agoWhat's a good IDE for Go? Something that's snappy and fast, no Java dinosaurs please
- 12298765 8y agoI mean GoLand is pretty good, but I do also like IntelliJ, so YMMV if you don't like the JetBrains products. And it isn't free. VSCode is also really good for Go, I was surprised. There are plugins that massively help with testing, syntax checking, error handling, etc. I think it actually catches more issues than GoLand!
- rnvhhynr 8y agoI've tried VSCode but it seems to require you to install Go... It can't even find the declaration of a variable or the definition of a function without Go, while Sublime can.
- xdfgd0ig0dg 8y agoVisual Studio Code with the official go extension is really great and snappy
- deleted 8y ago[deleted]
- geoka9 8y agoEmacs with go-guru.