-2
は、私がこれ持っている:今、私はpkg1.PkgApiCall()
を呼び出したい同じシグネチャで関数型を変換するにはどうすればよいですか?パッケージで
type MyFuncType func (a interface{}, b interface{}) int
が、MyFuncType
の変数を持つ:このパッケージを使用して私のコードで
package pkg1
type SomeFuncType func (a interface{}, b interface{}) int
func PkgApiCall (x SomeFuncType) {
...
}
を、私はいくつかの非常に類似したを持っています引数として:
package mypackage
func doingSomeThing(x MyFuncType) {
pkg1.PkgApiCall(x)
}
コンパイルされません。エラーが発生する
./src1.go:97:7: error: incompatible type in initialization (cannot use type mypackage.MyFuncType as type pkg1.SomeFuncType)
どうすればこの問題を解決できますか?これらの関数型は、まったく同じシグネチャを持つ関数を定義します。