Hacker News new | ask | show | jobs
by NateDad 4255 days ago
The context example is the only one of these that is really a valid example - and that is not something you would normally run into. I've never seen that idiom in code outside of google, so I wouldn't even call it idiomatic, regardless of the fact that it's posted on the Go blog. I'm actually sort of surprised they even posted it there.

The JSON package is handling automatic marshalling of objects to and from a textual format - of course it has to be outside the scope of normal code.

When I said "you can code for a very long time without hitting your first interface{}", I meant in code you write. It's very rare to need interface{} in your own code. Some very specialized packages (like JSON) need it, and yes, sometimes helper functions for testing need it. But for regular production code? No. If you find yourself reaching for interface{} more than extremely rarely in your code, you're probably doing something wrong.