code: func Validate(email string) error {
  	if len(email) < 6 || len(email) > 254 {
  		return ErrInvalidFormat
  	}
  
  	at := strings.LastIndex(email, "@")
  	if at <= 0 || at > len(email)-3 {
  		return ErrInvalidFormat
  	}
  
  	user := email[:at]
  	host := email[at+1:]
  
  	if len(user) > 64 {
  		return ErrInvalidFormat
  	}
  	if userDotRegexp.MatchString(user) || !userRegexp.MatchString(user) || !hostRegexp.MatchString(host) {
  		return ErrInvalidFormat
  	}
  
  	switch host {
  	case "localhost", "example.com":
  		return nil
  	}
  
  	if _, err := net.LookupMX(host); err != nil {
  		if _, err := net.LookupIP(host); err != nil {
  			// Only fail if both MX and A records are missing - any of the
  			// two is enough for an email to be deliverable
  			return ErrUnresolvableHost
  		}
  	}
  
  	return nil
  }
docs: // Validate checks format of a given email and resolves its host name.