0
我想創建一個函數,接收多種類型的結構並將這些指針值添加到另一個函數。GO多指針
實施例:
type Model1 struct {
Name string
}
type Model2 struct {
Type bool
}
func MyFunc(value ...interface{}) {
OtherFunc(value...)
}
func main() {
MyFunc(new(Model), new(Mode2));
}
的問題是,OtherFunc
只允許&value, &value, etc
作爲參數。有辦法通過像OtherFunc(&value...)
這些值?
'OtherFunc'的簽名是什麼?它是'OtherFunc(values ... inteface {})'還是別的? – captncraig
我使用** gorm **,簽名是'func(s * DB)AutoMigrate(values ... interface {})* DB' –