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: about 1 month 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 5 years ago)
- Default Branch: master
- Last Pushed: 2025-01-26T09:15:09.000Z (10 months ago)
- Last Synced: 2025-04-01T09:15:51.011Z (8 months ago)
- Topics: email, go, golang, normalization
- Language: Go
- Homepage:
- Size: 41 KB
- Stars: 68
- Watchers: 2
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-plus - go-email-normalizer - Golang library for providing a canonical representation of email address.  (Email / Search and Analytic Databases)
- awesome-go - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- fucking-awesome-go - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- awesome-go-cn - go-email-normalizer - email-normalizer) (电子邮件 / 检索及分析资料库)
- awesome-go - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- awesome-go - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- awesome-go-cn - go-email-normalizer - email-normalizer) (电子邮件 / 检索及分析资料库)
- awesome-go-cn - go-email-normalizer
- awesome-go - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- awesome-go-extra - go-email-normalizer - 08-21T23:13:04Z|2021-09-18T11:31:53Z| (Email / Advanced Console UIs)
- awesome-go-with-stars - go-email-normalizer - Golang library for providing a canonical representation of email address. (Email / Search and Analytic Databases)
- awesome-go - dimuska139/go-email-normalizer
- 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)
README
# go-email-normalizer - email normalization for Go
[](https://pkg.go.dev/github.com/dimuska139/tilda-go)
[](https://codecov.io/gh/dimuska139/go-email-normalizer)
[](https://goreportcard.com/report/github.com/dimuska139/go-email-normalizer)
[](https://github.com/dimuska139/go-email-normalizer/blob/master/LICENSE)
[](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/v5
```
## Usage
```go
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("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("John+Brown@yahoo.com")) // john+brown@yahoo.com
fmt.Println(n.Normalize("John-Brown@yahoo.com")) // john@yahoo.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 other rules using `AddRule` function (see an example above)