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: 3 days ago
JSON representation
Golang library for providing a canonical representation of email address.
- Host: GitHub
- URL: https://github.com/dimuska139/go-email-normalizer
- Owner: dimuska139
- License: mit
- Created: 2020-08-21T23:13:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T20:34:26.000Z (5 months ago)
- Last Synced: 2024-09-07T00:03:28.034Z (5 months ago)
- Topics: email, go, golang, normalization
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 64
- Watchers: 2
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- awesome-Char - go-email-normalizer - Golang library for providing a canonical representation of email address. (Authentication and OAuth / Contents)
- awesome-go-cn - go-email-normalizer
- awesome-go-extra - go-email-normalizer - 08-21T23:13:04Z|2021-09-18T11:31:53Z| (Email / Advanced Console UIs)
README
# go-email-normalizer - email normalization for Go
[![Go Reference](https://pkg.go.dev/badge/github.com/dimuska139/go-email-normalizer.svg)](https://pkg.go.dev/github.com/dimuska139/tilda-go)
[![codecov](https://codecov.io/github/dimuska139/go-email-normalizer/graph/badge.svg?token=E1TagDCBXc)](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/v4
```## Usage
```go
package mainimport (
"fmt"
"strings"
normalizer "github.com/dimuska139/go-email-normalizer/v4"
)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
* Microsoft
* Protonmail
* Rackspace
* Rambler
* Yahoo
* Yandex
* ZohoAlso you can integrate other rules using `AddRule` function (see an example above)