For some Go code, a single struct might implement multiple interfaces.
For example:
type IType1 interface {
Method1() error
}
type IType2 interface {
Method2() string
}
func DoWork(input IType1) error {
if err := input.Method1(); err != nil {
return err
}
if i2, ok := input.(IType2); !ok {
return error.New("does not implement IType2")
}
fmt.Println(i2.Method2())
return nil
}
This helps with plug and play code, where you are accepting outside objects to execute logic on more than one interface.
Suggested generate command can be:
pegomock generate github.com/path/to/pkg IType1 github.com/path/to/other/pkg IType2