I'd like to create a "set" of gorm types used in my application. So I'd like to define a map with my types gorm.DB as keys and empty structs{} as flags:
var (
autoMigrations map[gorm.DB]struct{}
)
But compiler doesn't allow me do this with error: invalid map key type gorm.DB. I can fool it using pointers to gorm.DBs like:
map[*gorm.DB]struct{}
But it's not a solution, because I need to make it unique and if my map gets filled like db.AutoMigrate(&Chat{}) I can get lots of similar object with different addresses.
Another solution is to make a slice of gorm.DB:
autoMigrations []gorm.DB
But I have to filter elements on addition manually, which seems insane a little bit.