I have created a type Role based off string, and I am now trying to get it to work with the database driver by implementing the Valuer and Scanner interfaces
type Role string
func (r *Role) Scan(value interface{}) error {
r = (*Role)(value.(string))
return nil
}
func (r *Role) Value(value driver.Value, err error) {
if err != nil {
value = string(r)
}
}
I keep getting the error:
The Go code app/entities/user.go does not compile: cannot convert value.(string) (type string) to type *Role
What am I doing wrong here?