title: Validation using golang, gin and gorm with postgres like email already exist in database
body: <p><a href="https://i.stack.imgur.com/bksjo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bksjo.png" alt="enter image description here" /></a>I have something like this and I would like to check if email already exist in DB:</p>
  <pre><code>func RegisterUser(c *gin) {
  var user models.User
  if err := c.ShouldBindJSON(&amp;user); err != nil {
      c.JSON(http.StatusBadRequest, gin.H{
          &quot;messAge&quot;: err.Error(),
          &quot;data&quot;:    &quot;&quot;,
      })
      return
  }
  // **I TRIED SOEMTHING LIKE THIS**
  err := database.DB.Find(&amp;user.Email).Error
  if err != nil {
      c.JSON(401, gin.H{&quot;MESSAGE&quot;: &quot;Email ALREADY exist&quot;,
      return
  }
  // **but is not working, because ANY mail it give me error**
  
  
  if !strings.Contains(user.Email, &quot;@&quot;) {
      c.JSON(400, gin.H{&quot;MESSAGE&quot;: utils.ErrEmailWrong})
      return
  }
  
  if len(user.Password) &lt; 4 {
      c.JSON(400, gin.H{&quot;MESSAGE&quot;: utils.ErrPasswordLength})
      return
  }
  
  database.DB.Create(&amp;user)
  c.JSON(200, gin.H{
      &quot;MESSAGE&quot;: &quot;CREATED&quot;,
  })
  }
  </code></pre>
  <p>With this code, every time is telling me that : Email already exist, only works for the first time.</p>