addr

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package addr normalizes email addresses, domain names and host names, the one place deciding what lfr accepts as an address.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("invalid address")

ErrInvalid matches every error about a malformed address or domain, so callers can tell bad input from failures without reading the message.

Functions

func Base

func Base(local string) string

Base strips a +tag from a local part: "jo+news" → "jo".

func Domain

func Domain(s string) (string, error)

Domain returns the lowercase ASCII (punycode) form of a domain or host name.

func DomainOf

func DomainOf(email string) string

DomainOf returns the domain of an address, or "" when it has none.

func Email

func Email(s string) (string, error)

Email parses and returns the normalized address string.

func Invalid

func Invalid(format string, args ...any) error

Invalid is an error about a malformed address that matches ErrInvalid.

func Local

func Local(s string) (string, error)

Local validates and lowercases a local part as lfr hands them out: letters, digits and . _ - + only, no leading or trailing dot.

Types

type Address

type Address struct{ Local, Domain string }

Address is a normalized mailbox address.

func Parse

func Parse(s string) (Address, error)

Parse accepts a bare address or "Name <addr>" and normalizes it. The local part keeps its characters (other servers' addresses may use anything RFC 5321 allows) but is lowercased, which every real mail system treats alike.

func (Address) String

func (a Address) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL