Go Library for Providing a Canonical Representation of Email Address

Go-email-normalizer - email normalization for Go

This is Golang library for providing a canonical representation of email address. It allows to prevent multiple signups. go-email-normalizer contains some popular providers but you can easily append others.

Download

go get github.com/dimuska139/go-email-normalizer

Usage

package main

import (
    "fmt"
    "strings"
    normalizer "github.com/dimuska139/go-email-normalizer"
)

type customRule struct {}

func (rule *customRule) ProcessUsername(username string) string {
    return strings.Replace(username, "-", "", -1)
}

func (rule *customRule) ProcessDomain(domain string) string {
    return domain
}

func main() {
    n := normalizer.NewNormalizer()
    fmt.Println(n.Normalize("vasya+pupkin@gmail.com")) // vasya@gmail.com
    fmt.Println(n.Normalize("t.e-St+vasya@gmail.com")) // te-st@gmail.com
    fmt.Println(n.Normalize("t.e-St+@googlemail.com")) // te-st@gmail.com
    fmt.Println(n.Normalize("t.e-St+@google.com")) // te-st@gmail.com
    
    n.AddRule("customrules.com", &customRule{})
    fmt.Println(n.Normalize(" tE-S-t@CustomRules.com.")) // tESt@customrules.com
}

Supported providers

  • Apple
  • Fastmail
  • Google
  • Microsoft
  • Protonmail
  • Rackspace
  • Rambler
  • Yahoo
  • Yandex
  • Zoho

Also you can integrate another rules using AddRule function (see an example above)


Download Details:

Author: Dimuska139
Source Code: https://github.com/dimuska139/go-email-normalizer 
License: MIT license

#go #golang #email

Go Library for Providing a Canonical Representation of Email Address
1.00 GEEK