title: How to validate an email address in Go
body: <p>I have checked the StackOverflow and couldn't find any question that answers <strong>how to validate email in Go Language</strong>.</p>
  <p>After some research, I figured out and solved it as per my need.</p>
  <p>I have this <strong>regex</strong> and <strong>Go function</strong>, which work fine:</p>
  <pre><code>import (
      &quot;fmt&quot;
      &quot;regexp&quot;
  )
  
  func main() {
      fmt.Println(isEmailValid(&quot;test44@gmail.com&quot;)) // true
      fmt.Println(isEmailValid(&quot;test$@gmail.com&quot;)) // true -- expected &quot;false&quot; 
  }
  
  
  // isEmailValid checks if the email provided is valid by regex.
  func isEmailValid(e string) bool {
      emailRegex := regexp.MustCompile(&quot;^[a-zA-Z0-9.!#$%&amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$&quot;)
      return emailRegex.MatchString(e)
  }
  </code></pre>
  <p>The problem is that <strong>it accepts the special characters that I don't want</strong>. I tried to use some from other languages' &quot;regex&quot; expression, but it throws the error <strong>&quot;unknown escape&quot;</strong> in debug.</p>
  <p>Could anyone give me a good regex or any fast solution (pkg) that works with GoLang?</p>