Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/dimuska139/go-email-normalizer

Golang library for providing a canonical representation of email address.
https://github.com/dimuska139/go-email-normalizer

email go golang normalization

Last synced: 24 days ago
JSON representation

Golang library for providing a canonical representation of email address.

Lists

README

        

# go-email-normalizer - email normalization for Go

[![Build Status](https://travis-ci.org/dimuska139/go-email-normalizer.svg?branch=master)](https://travis-ci.org/dimuska139/go-email-normalizer)
[![codecov](https://codecov.io/gh/dimuska139/go-email-normalizer/branch/master/graph/badge.svg)](https://codecov.io/gh/dimuska139/go-email-normalizer)
[![Go Report Card](https://goreportcard.com/badge/github.com/dimuska139/go-email-normalizer)](https://goreportcard.com/report/github.com/dimuska139/go-email-normalizer)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimuska139/go-email-normalizer/blob/master/LICENSE)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/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

```shell
go get -u github.com/dimuska139/go-email-normalizer/v2
```

## Usage

```go
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]
}
```

## 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)