In a package, I have this:
package pkg1
type SomeFuncType func (a interface{}, b interface{}) int
func PkgApiCall (x SomeFuncType) {
...
}
In my code using this package, I have some very similar:
type MyFuncType func (a interface{}, b interface{}) int
Now I want to call pkg1.PkgApiCall()
, but with a variable of MyFuncType
as argument:
package mypackage
func doingSomeThing(x MyFuncType) {
pkg1.PkgApiCall(x)
}
It doesn't compile. I get the error
./src1.go:97:7: error: incompatible type in initialization (cannot use type mypackage.MyFuncType as type pkg1.SomeFuncType)
How could I get over this? These function types define functions with exactly the same signature.