
如何给 Go 的结构体添加多个 tag
本来很简单的东西,但是老忘,干脆写个博客吧 错误写法 type Page struct { PageId string `bson:"pageId",json:"pageId"` Meta map[string]interface{} `bson:"meta",json:"pageId"` } 正确写法 type Page struct { PageId string `bson:"pageId" json:"pageId"` Meta map[string]interface{} `bson:"meta" json:"pageId"` } 很多 Tag Items []Item `gorm:"column:items,type:varchar(255);comment:'sample column'" json:"items"` 参考链接 StackOverflow - How to define multiple name tags in a struct