|
|
|
|
|
by svnpenn
1542 days ago
|
|
> Much easier than implementing the error interface in go. is this a joke? You have to import a third party package, just to implement
an error interface? Here is Go example, no imports: type errorString string
func (e errorString) Error() string {
return string(e)
}
|
|
Let's look at a common example: you want to return two different types of errors and have the caller distinguish between them. Let me show it to you in rust and go.
Rust:
The equivalent go would be something like: