gorm mysql unique constraint show errors example
type GormErr struct {
Number int `json:"Number"`
Message string `json:"Message"`
}
err, _ = DoFuncOnDB(); // funtion to do some ops on DB
byteErr, _ := json.Marshal(err)
var newError types.GormErr
json.Unmarshal((byteErr), &newError)
switch newError.Number {
case 1062: fmt.Println("Duplicate key Error")
}