Awesome Go

go-email-normalizer

CategoryEmail
SubcategoryEmail
Stars0

Golang library for providing a canonical representation of email address

About go-email-normalizer

go-email-normalizer - email normalization for Go

Go Reference codecov Go Report Card License Mentioned in Awesome 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 -u github.com/dimuska139/go-email-normalizer/v5

Usage

package main

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

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]
	fmt.Println(n.Normalize("[email protected]"))     // [email protected]
	
	n.AddRule("customrules.com", &customRule{})
	fmt.Println(n.Normalize(" [email protected].")) // [email protected]
}

Supported providers

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

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

Frequently Asked Questions

What is go-email-normalizer?

go-email-normalizer is a Email library for the Go programming language. Golang library for providing a canonical representation of email address

How do I install go-email-normalizer?

Install go-email-normalizer with the Go module system using `go get dimuska139/go-email-normalizer`. Check the repository for the current installation instructions.

What category does go-email-normalizer belong to?

go-email-normalizer is listed under Email, specifically Email.

← Back to Email