Basically I want to have an interface which has a SetParams
method, the declaration of which declares it receives one parameter, and the return type of the method, but leaves the return type of the parameter up to the receiver.
Something like this interface:
type ParamsInterface interface {
SetParams(<someType>) ParamsInterface
}
Now, when XStruct
implements it, the type of the parameters is XParams
type XStruct struct {
params XParams
}
func (x *XStruct) SetParams(params *XParams) ParamsInterface {
x.params = params
return x
}
But when YStruct
implements it, the type of the parameters is YParams
type YStruct struct {
params YParams
}
func (y *YStruct) SetParams(params *YParams) ParamsInterface {
y.params = params
return y
}