13.6 Practical Uses: Unwrapping Errors and Protocol Detection
Right, let’s get our hands dirty with the two places you’ll most often reach for type assertions and switches outside of your own code: pulling useful information out of errors and figuring out what you’re really talking to over a network. The standard library, in its infinite wisdom, gives us the error interface. It’s beautifully simple: one method, Error() string. This is also its biggest flaw. When something goes wrong, you get a string. Just a string. It’s like a car mechanic handing you a note that just says “broken.” Thanks. Helpful.