Hacker News new | ask | show | jobs
by 4death4 842 days ago
In many cases, you don’t really need to check pointers unless you specifically want to handle the nil case. Go’s panic / recover feature lets you “catch” nil pointer access elsewhere. For instance, if you have an HTTP handler, it’s way easy to install a middleware that recovers from panics than it is to check for nil everywhere.
1 comments

The point of having it in the type system is not just to force you to check it. It is also to clearly document where you need to check it, and just as important, where you don't.

Without it, you don't have that "this is guaranteed to exist at this point" indication that can actually reduce the overall number of checks in practice.

I get what you’re saying, but it just rarely turns out to be an issue in Go. Not sure why.