我是学习 Go 的新手,并且有一个关于定义可能是两种类型之一的论点的问题。拿下代码:
type Thing struct {
a int
b int
c string
d string
}
type OtherThing struct {
e int
f int
c string
d string
}
func doSomething(t Thing/OtherThing) error {
fmt.println(t.d)
return nil
}
由于结构没有功能,我目前无法为它们编写接口。那么这里的 Go 惯用的事情是什么?是否只是将随机函数附加到结构并编写接口或其他东西?
谢谢您的帮助...
MYYA
心有法竹
一只名叫tom的猫
相关分类