【发布时间】:2015-01-26 12:30:46
【问题描述】:
我有一个功能
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{} 兼容?
【问题讨论】:
标签: pointers struct interface casting go