I would like to use Gorp to load and save structs from the DB that contain specialised types. Amongst other things, this is useful for enumerated strings such as roles:
type Role string
type Account struct {
User string
Role Role
}
This doesn't work "out of the box". An error message is raised such as
panic: sql: converting Exec argument #0's type: unsupported type user.Role, a string
I suspect I need to use a gorp.TypeConverter
to solve this, but there is no documentation on how to do this.
Can you help?
Valuer and Scanner interfaces will do what you want. Here is a working example :