Categorygithub.com/goware/emailx
modulepackage
0.2.0
Repository: https://github.com/goware/emailx.git
Documentation: pkg.go.dev

# README

emailx

Golang pkg for email validation and normalization.

GoDoc Travis

Email validation

  • Simple email format check (not a complicated regexp, this is why)
  • Resolve the host name
import "github.com/goware/emailx"

func main() {
    err := emailx.Validate("[email protected]")
    if err != nil {
        fmt.Println("Email is not valid.")

        if err == emailx.ErrInvalidFormat {
            fmt.Println("Wrong format.")
        }

        if err == emailx.ErrUnresolvableHost {
            fmt.Println("Unresolvable host.")
        }
    }
}

Email normalization

import "github.com/goware/emailx"

func main() {
    fmt.Print(emailx.Normalize(" [email protected]. "))
    // Prints [email protected]
}

License

Emailx is licensed under the MIT License.

# Functions

Normalize normalizes email address.
Validate checks format of a given email and resolves its host name.
ValidateFast checks format of a given email.

# Variables

ErrInvalidFormat returns when email's format is invalid.
ErrUnresolvableHost returns when validator couldn't resolve email's host.