I had written a lazy code to demonstrate the issue I am having to implement interfaces. I have methods M1, M2 that take struct X as an argument and have a type of struct Y. I wanted all these methods to be implemented by a single interface I. The issue is the method M that implements the interface I needs to be aware of the arguments that are required to be passed to the child methods (M1,M2). I get an error: <argument name> used as a value
when I pass multiple arguments in M
type Y struct {
a int
}
type X struct {
a int
}
(y *Y) func M1(x X) struct {
return y.a+x.a
}
(y *Y) func M2(x X) struct {
return y.a*x.a
}
type I interface {
M1(x X)
M2(x X)
}
func M(i I, x X) {
fmt.println(i.M1(x)) //returns an error i.M1(x) used as a value
fmt.println(i.M2(x)) //returns an error i.M2(x) used as a value
}