I'm using PostgreSQL and GORM in my Go app.
I thought that using the sql tab of sql:"not null"
would do the trick of preventing a null entry, but when go initializes structs with a string type then it defaults to an empty string which is not the same as null in the db.
I am wondering if there is a way to prevent this from happening in a struct definition so I wouldn't have to strictly enforce it at all levels in the application code.
gorm:"default:'empty'"
. Or prevent calls to db.Create at application level. – Atheroma