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: 6 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: 2025-01-26T09:15:09.000Z (3 months ago)
- Last Synced: 2025-04-01T09:15:51.011Z (14 days 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 - 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
[](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 mainimport (
"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
* Microsoft
* Protonmail
* Rackspace
* Rambler
* Yahoo
* Yandex
* ZohoAlso you can integrate other rules using `AddRule` function (see an example above)