在golang中,interface{}允许接纳任意值,int,string,struct,slice等,因此我可以很简单的将值传递到interface{},例如:package mainimport ( 'fmt')type User struct{ Name string}func main()...
我就废话不多说了,大家还是直接看代码吧~type Animal struct { ID int64 Name string `gorm:'default:’galeone’'` Age int64} 把 name 设置上缺省值 galeone 了。补充:Golang 巧用构造函数设置结构体的默认值看...