I have this struct for user
type User struct {
gorm.Model
Username string `gorm:"not null;unique" json:"username"`
Password *string `gorm:"not null"json:"password,omitempty"`
Email string `gorm:"not null;unique"json:"email"`
Addresses *[]UserAddress `json:"addresses,omitempty"`
}
When I bind json to my struct I can save password to the database like this
userObj := User{}
password := *userObj.Password
userObj.Password = &password
db.Debug().Save(&userObj)
The part that is not working is when I try to apply the same thing for Addresses field. Error from terminal is this "field value not valid".
Here's the playground link