I've worked with C# for years so I'm trying to find similarities in GO (I'm quite new to this).
My goal:
I would like to extend the interface error
by a method like Check()
so I'm able to call error.Check()
just because of a (in my opinion) better readable code.
My current state:
I've already learned how to extend types by methods with this syntax:
func (foo T) MyExtension() returnType {
// return something
}
My problem:
It looks like this only applies to types but not interfaces. As I've seen so far error
is an interface
that's used by many packages to describe a base of their own error-types. I dont want to extend this error-types (from packages) but rather want to extend the interface to cover them all. I couldn't find any syntax for that. As I also don't know the technical term for this (its not extension-method
) I'm a bit lost in googling around.
So is there a way to extend the error
interface by a general method?