Reputation: 4266
Interface inheritance looks like the following in C#:
interface IA{
void MethodX();
}
interface IB : IA{
void MethodY();
}
How can I reuse interface definition in go?
Upvotes: 20
Views: 22021
Reputation: 680
I guess that you don't need inheritance, Golang tests if your struct implements related method in interface so a struct can implement many interfaces
Upvotes: -1
Reputation: 871
You can embed other interfaces inside an interface, which gives you basicaly the same benefits:
A Good Example is the ReadWriteCloser
in the io package:
http://golang.org/pkg/io/#ReadWriteCloser
It embeds a Reader
, a Writer
and a Closer
interface.
Upvotes: 36