News for hackers. Stuff that matters.
Re:The Tao of Go by arianvanp on Wednesday February 12, 2025 @05:17AM (#43023843)
> We accept interface values, as the Go proverb says, so that we need make the fewest assumptions about what they are, but we return concrete values (structs), which save users from writing lots of type assertions about them.

I wish go people actually did this. Also it's just not true. The standard library is full of private structs that are returned as interfaces. Just look at the net library for example. Non of the listener structs are exposed. Only the net.Listener interface

And of course the biggest offender is error which is an interface and the return value of basically every function. And you're basically writing type assertions all day

There are no comments on this comment yet.