Documentation
¶
Index ¶
- type AppleRule
- type Change
- type FastmailRule
- func (rule *FastmailRule) ProcessDomain(domain string) string
- func (rule *FastmailRule) ProcessDomainWithChanges(domain string) (string, []Change)
- func (rule *FastmailRule) ProcessUsername(username string) string
- func (rule *FastmailRule) ProcessUsernameWithChanges(username string) (string, []Change)
- type GoogleRule
- type MicrosoftRule
- func (rule *MicrosoftRule) ProcessDomain(domain string) string
- func (rule *MicrosoftRule) ProcessDomainWithChanges(domain string) (string, []Change)
- func (rule *MicrosoftRule) ProcessUsername(username string) string
- func (rule *MicrosoftRule) ProcessUsernameWithChanges(username string) (string, []Change)
- type NormalizeResult
- type Normalizer
- type NormalizingRule
- type NormalizingRuleWithChanges
- type ProtonmailRule
- func (rule *ProtonmailRule) ProcessDomain(domain string) string
- func (rule *ProtonmailRule) ProcessDomainWithChanges(domain string) (string, []Change)
- func (rule *ProtonmailRule) ProcessUsername(username string) string
- func (rule *ProtonmailRule) ProcessUsernameWithChanges(username string) (string, []Change)
- type RackspaceRule
- func (rule *RackspaceRule) ProcessDomain(domain string) string
- func (rule *RackspaceRule) ProcessDomainWithChanges(domain string) (string, []Change)
- func (rule *RackspaceRule) ProcessUsername(username string) string
- func (rule *RackspaceRule) ProcessUsernameWithChanges(username string) (string, []Change)
- type RamblerRule
- type YahooRule
- type YandexRule
- type ZohoRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppleRule ¶
type AppleRule struct {
}
AppleRule : email normalization rule for Apple
func (*AppleRule) ProcessDomain ¶
func (*AppleRule) ProcessDomainWithChanges ¶
func (*AppleRule) ProcessUsername ¶
type Change ¶
type Change string
Change is a string enum identifying a single transformation applied to an email address during normalization. It is returned by Normalize2.
const ( // ChangeTrimmedWhitespace is applied when leading or trailing whitespace is // removed from the raw input. ChangeTrimmedWhitespace Change = "trimmed_whitespace" // ChangeRemovedTrailingDot is applied when one or more trailing dots are // stripped from the raw input. ChangeRemovedTrailingDot Change = "removed_trailing_dot" // ChangeLowercase is applied when the username or domain contains uppercase // letters that are converted to lower case. ChangeLowercase Change = "lowercase" // ChangeRemovedDots is applied when dot characters are removed from the // username (e.g. Google, Protonmail). ChangeRemovedDots Change = "removed_dots" // ChangeRemovedUnderscores is applied when underscore characters are removed // from the username (e.g. Protonmail). ChangeRemovedUnderscores Change = "removed_underscores" // ChangeRemovedHyphens is applied when hyphen characters are removed from // the username (e.g. Protonmail). ChangeRemovedHyphens Change = "removed_hyphens" // ChangeReplacedHyphensWithDots is applied when hyphen characters in the // username are replaced with dots (e.g. Yandex). ChangeReplacedHyphensWithDots Change = "replaced_hyphens_with_dots" // ChangeRemovedPlusTag is applied when a plus-sign subaddress ("+tag") is // stripped from the end of the username (e.g. Google, Apple, Fastmail, // Protonmail). ChangeRemovedPlusTag Change = "removed_plus_tag" // ChangeRemovedPlusSigns is applied when plus-sign characters are removed // from the username without subaddress semantics — every "+" is deleted // regardless of position (e.g. Microsoft, Rackspace, Rambler, Yandex, Zoho). ChangeRemovedPlusSigns Change = "removed_plus_signs" // ChangeRemovedSubaddress is applied when a dash-delimited subaddress // ("-tag") is stripped from the end of the username (e.g. Yahoo). ChangeRemovedSubaddress Change = "removed_subaddress" // ChangeCanonicalisedDomain is applied when the domain is rewritten to its // canonical form (e.g. googlemail.com → gmail.com, me.com → icloud.com, // ya.ru → yandex.ru). ChangeCanonicalisedDomain Change = "canonicalized_domain" )
type FastmailRule ¶
type FastmailRule struct {
}
FastmailRule : email normalization rule for Fastmail
func (*FastmailRule) ProcessDomain ¶
func (rule *FastmailRule) ProcessDomain(domain string) string
func (*FastmailRule) ProcessDomainWithChanges ¶
func (rule *FastmailRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*FastmailRule) ProcessUsername ¶
func (rule *FastmailRule) ProcessUsername(username string) string
func (*FastmailRule) ProcessUsernameWithChanges ¶
func (rule *FastmailRule) ProcessUsernameWithChanges(username string) (string, []Change)
type GoogleRule ¶
type GoogleRule struct {
}
GoogleRule : email normalization rule for Google
func (*GoogleRule) ProcessDomain ¶
func (rule *GoogleRule) ProcessDomain(domain string) string
func (*GoogleRule) ProcessDomainWithChanges ¶
func (rule *GoogleRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*GoogleRule) ProcessUsername ¶
func (rule *GoogleRule) ProcessUsername(username string) string
func (*GoogleRule) ProcessUsernameWithChanges ¶
func (rule *GoogleRule) ProcessUsernameWithChanges(username string) (string, []Change)
type MicrosoftRule ¶
type MicrosoftRule struct {
}
MicrosoftRule : email normalization rule for Microsoft
func (*MicrosoftRule) ProcessDomain ¶
func (rule *MicrosoftRule) ProcessDomain(domain string) string
func (*MicrosoftRule) ProcessDomainWithChanges ¶
func (rule *MicrosoftRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*MicrosoftRule) ProcessUsername ¶
func (rule *MicrosoftRule) ProcessUsername(username string) string
func (*MicrosoftRule) ProcessUsernameWithChanges ¶
func (rule *MicrosoftRule) ProcessUsernameWithChanges(username string) (string, []Change)
type NormalizeResult ¶
type NormalizeResult struct {
// Normalized is the canonical form of the email address.
Normalized string
// Changes lists every transformation that was applied, in the order they
// were first detected. Each Change value appears at most once.
Changes []Change
}
NormalizeResult is the return value of Normalize2.
type Normalizer ¶
type Normalizer struct {
// contains filtered or unexported fields
}
Normalizer : main library object for normalization emails
func (*Normalizer) AddRule ¶
func (n *Normalizer) AddRule(domain string, strategy NormalizingRule)
AddRule : appends custom normalization rule
func (*Normalizer) Normalize ¶
func (n *Normalizer) Normalize(email string) string
Normalize : converts email to canonical form
func (*Normalizer) Normalize2 ¶
func (n *Normalizer) Normalize2(email string) NormalizeResult
Normalize2 : converts email to canonical form and returns a NormalizeResult that includes both the normalized address and every transformation applied.
Rules registered via AddRule that only implement NormalizingRule (not NormalizingRuleWithChanges) are still fully supported — the normalized address will be correct, but per-rule changes will not be reported. Pre-processing changes (whitespace trimming, trailing-dot removal, domain lowercasing) are always tracked regardless of the rule type.
type NormalizingRule ¶
NormalizingRule : interface for all email normalization rules
type NormalizingRuleWithChanges ¶
type NormalizingRuleWithChanges interface {
NormalizingRule
ProcessUsernameWithChanges(username string) (result string, changes []Change)
ProcessDomainWithChanges(domain string) (result string, changes []Change)
}
NormalizingRuleWithChanges is an optional extension of NormalizingRule. Rules that implement it allow Normalize2 to report the individual transformations applied to the username and domain. Rules added via AddRule that only satisfy NormalizingRule are still supported by Normalize2 — they will not report per-rule changes, but global pre-processing changes (whitespace trimming, trailing-dot removal, domain lowercasing) are always tracked.
type ProtonmailRule ¶
type ProtonmailRule struct {
}
ProtonmailRule : email normalization rule for Protonmail
func (*ProtonmailRule) ProcessDomain ¶
func (rule *ProtonmailRule) ProcessDomain(domain string) string
func (*ProtonmailRule) ProcessDomainWithChanges ¶
func (rule *ProtonmailRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*ProtonmailRule) ProcessUsername ¶
func (rule *ProtonmailRule) ProcessUsername(username string) string
func (*ProtonmailRule) ProcessUsernameWithChanges ¶
func (rule *ProtonmailRule) ProcessUsernameWithChanges(username string) (string, []Change)
type RackspaceRule ¶
type RackspaceRule struct {
}
RackspaceRule : email normalization rule for Rackspace
func (*RackspaceRule) ProcessDomain ¶
func (rule *RackspaceRule) ProcessDomain(domain string) string
func (*RackspaceRule) ProcessDomainWithChanges ¶
func (rule *RackspaceRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*RackspaceRule) ProcessUsername ¶
func (rule *RackspaceRule) ProcessUsername(username string) string
func (*RackspaceRule) ProcessUsernameWithChanges ¶
func (rule *RackspaceRule) ProcessUsernameWithChanges(username string) (string, []Change)
type RamblerRule ¶
type RamblerRule struct {
}
RamblerRule : email normalization rule for Rambler
func (*RamblerRule) ProcessDomain ¶
func (rule *RamblerRule) ProcessDomain(domain string) string
func (*RamblerRule) ProcessDomainWithChanges ¶
func (rule *RamblerRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*RamblerRule) ProcessUsername ¶
func (rule *RamblerRule) ProcessUsername(username string) string
func (*RamblerRule) ProcessUsernameWithChanges ¶
func (rule *RamblerRule) ProcessUsernameWithChanges(username string) (string, []Change)
type YahooRule ¶
type YahooRule struct {
}
YahooRule : email normalization rule for Yahoo
func (*YahooRule) ProcessDomain ¶
func (*YahooRule) ProcessDomainWithChanges ¶
func (*YahooRule) ProcessUsername ¶
type YandexRule ¶
type YandexRule struct {
}
YandexRule : email normalization rule for Yandex
func (*YandexRule) ProcessDomain ¶
func (rule *YandexRule) ProcessDomain(domain string) string
func (*YandexRule) ProcessDomainWithChanges ¶
func (rule *YandexRule) ProcessDomainWithChanges(domain string) (string, []Change)
func (*YandexRule) ProcessUsername ¶
func (rule *YandexRule) ProcessUsername(username string) string
func (*YandexRule) ProcessUsernameWithChanges ¶
func (rule *YandexRule) ProcessUsernameWithChanges(username string) (string, []Change)
type ZohoRule ¶
type ZohoRule struct {
}
ZohoRule : email normalization rule for Zoho