So I have a struct, something like this:
type Torrent struct {
ID uint64 `db:"id"`
Metadata Metadata `db:"metadata"`
Category uint8 `db:"category"`
// Many other fields
}
Metadata
is an interface type, in SQL is a LONGTEXT (MariaDB's JSON type). So I have something like this:
type Metadata interface {
// multiple funcs
}
type Category1 struct {} // implementing Metadata interface
type Category2 struct {} // implementing Metadata interface
What I would like to do is somehow scan the data from SQL into the exact struct based on the Category
field. How could I achieve this?