3 ms·
Huh? They’re not strings. They’re an interface and you can create your own error type that implements the error interface, one of the requirements being that it
by alphabettsy 7y ago
Huh? They’re not strings. They’re an interface and you can create your own error type that implements the error interface, one of the requirements being that it has a string output available.
- ernst_klim 7y ago>They’re not strings. They are strings. They are implementation of interface with a single `to_string` method, after you got `error`, you can't say (you could use switch on type, but you should guess which type could it be), so basically you have an opaque object with a single `to_string` method, which is equivalent to string. I can't fancy a more error prone way than that which Go choose. How you match the errors, you match strings? You match types? You don't even know what types could there be, since all what the type system says is that function returns error.