Error handling in Go: Common pitfalls

5 months ago by CodyIT to c/golang

Developers coming to Go from languages that use try/catch constructs, like Java or C#, may feel a bit turned around. The inner voice suggests using ′recover′ with ′defer′ as the nearest equivalent...

When switching from other languages the urge to reach for recover/defer as a try/catch substitute is real

load all comments
I_quote_Seinfeld_a_lot 3 points 5 months ago

This reads very much like an ad for their static code analyzer. There is no real advice, just examples for what their software caught. I wonder how many of these would also be caught by golangci-lint.

path: 0 23646116, hotness: undefined, score: 3, children: 0
golang
golang

@programming.dev

login for more options
2783
315
17

This is a community dedicated to the go programming language.

Useful Links:

Rules:

  • Posts must be relevant to Go
  • No NSFW content
  • No hate speech, bigotry, etc
  • Try to keep discussions on topic
  • No spam of tools/companies/advertisements
  • It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

go to feed...