我有一个功能
func doStuff(inout *interface{}) {
...
}
此函数的目的是能够将任何类型的指针视为输入。但是当我想用结构的指针调用它时,我有一个错误。
type MyStruct struct {
f1 int
}
打电话时 doStuff
ms := MyStruct{1}
doStuff(&ms)
我有
test.go:38: cannot use &ms (type *MyStruct) as type **interface {} in argument to doStuff
我如何投射&ms才能与 兼容*interface{}?
相关分类