How can one struct implement both interfaces?
Well ... it depends if you're okay putting a wrapper around your "one struct."
If you find it unacceptable to wrap your struct ... then what the other contributors have written is spot on! It's true that Go doesn't permit such method overloading.
However, if you wrap your Implementer type ... then you can implement both interfaces without any problem.
Here is the work-around ...
type InterfaceA interface {
Init()
}
type InterfaceB interface {
Init(name string)
}
type Implementer struct{} // Your one struct
type ImpA Implementer // Wrapped version to implement InterfaceA
type ImpB Implementer // Wrapped version to implement InterfaceB
func (i ImpA) Init() {}
func (i ImpB) Init(name string) {}
If you go to the playground, you'll find that it runs fine!
Go playground to demonstrate the code above!
Also, it should be noted that elements of this question overlap with another stack overflow question with the following answer ...
Solution to: How to implement two different interfaces with the same method signature