You can implement multiple interfaces with a single struct, as below. You would then have methods accept the different interfaces as arguments.
If you need a single function which utilises methods from both interfaces you could just pass the pointer to your struct as separate arguments (one for each interface) but there is nothing stopping one interface satisfying multiple interfaces with a smaller scope so you could create a third interface which encapsulates the functionality of both to handle these situations (See IJ interface example).
package main
import (
"fmt"
)
type I interface {
A()
B()
}
// interface 'J' could be defined in an external package, it doesn't matter
type J interface {
C()
}
// encapsulate I & J interfaces as IJ
type IJ interface {
J
I
}
// S will satisfy interfaces I, J & IJ
type S struct {}
func (s *S) A(){
fmt.Println("A")
}
func (s *S) B(){
fmt.Println("B")
}
func (s *S) C(){
fmt.Println("C")
}
func main() {
s := &S{}
doWithI(s)
doWithJ(s)
fmt.Println("===================================")
doWithIAndJ(s)
}
func doWithI(in I){
in.A()
in.B()
}
func doWithJ(in J){
in.C()
}
func doWithIAndJ(in IJ){
in.A()
in.B()
in.C()
}
https://play.golang.org/p/DwH7Sr3zf_Y