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.
go get -u github.com/dimuska139/go-email-normalizer/v2
package main
import (
"fmt"
"strings"
normalizer "github.com/dimuska139/go-email-normalizer/v2"
)
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("[email protected]")) // [email protected]
fmt.Println(n.Normalize("[email protected]")) // [email protected]
fmt.Println(n.Normalize("[email protected]")) // [email protected]
fmt.Println(n.Normalize("[email protected]")) // [email protected]
fmt.Println(n.Normalize("[email protected]")) // [email protected]
n.AddRule("customrules.com", &customRule{})
fmt.Println(n.Normalize(" [email protected].")) // [email protected]
}
- Apple
- Fastmail
- Microsoft
- Protonmail
- Rackspace
- Rambler
- Yahoo
- Yandex
- Zoho
Also you can integrate other rules using AddRule
function (see an example above)