我注意到在 ORM 库 Gorm 中,您可以使用如下结构定义自定义表名:
type DeviceStatus struct {
// Define some Gorm model fields here
}
// TableName custumizes DeviceStatus SQL table name
func (DeviceStatus) TableName() string {
return "CustomDeviceStatusTableName"
}
这个结构叫什么?我试图用谷歌找到这个并弄清楚如何进行函数调用。
最佳答案
关于go - Go中结构本身的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61378026/