I am currently in the process of migrating from GORM V1 to V2. There is a decent amount of backwards compatibility but I am facing the following issue.
config.DB, err = gorm.Open(mysql.Open(config.DBDSN), &gorm.Config{})
if err != nil {
panic(err)
}
The code above shows how I connect to the mySQL db. The function below is causing an error.
func (b *Base) AddTags(model interface{}, modelID uint64, tagType models.TagType, tags []models.Tag) error {
err := b.config.DB.Model(model).Association(tagType.Field()).Append(tags).Error
if err != nil {
return err
}
return b.updateTagPriority(model, modelID, tagType, tags)
}
The error is
cannot use err (type func() string) as type error in return argument: func() string does not implement error (missing Error method)
I used the V2 release notes to refactor parts of the code but I can't figure out this particular issue. https://gorm.io/docs/v2_release_note.html I think there may be some significant change in error handling between V1 and V2