I'm using gorm
lib and to use that lib, I have to export all column fields. Something like this
type myType struct {
Id int
Name string
}
But with that, how to I deal with addition logics for struct fields. Let's say, what if I want to prefix Mr
to the Name
field? The client can always do myType.Name = "whatever"
. If I make Name
to be unexported and have setter for it, that field will never work with gorm
. Any golang-way to deal with this?