News for hackers. Stuff that matters.
Re:Fourteen Years of Go by randomdata on Friday November 17, 2023 @08:43AM (#38303415)
> If “getUserByID” returns a fake user

Logically, getUserByID returns nil when there is no user, not a fake user. The caller can then check for its nil-ness without needing to consider the error value. nil is a useful value. For better or worse, nil is how Go convention represents the absence of a value. In fact, convention sees error also rely on nil to be useful in the very same way.

It's funny how people completely forget how to write software as soon as they see the word error. Why is that?

There are no comments on this comment yet.