Standard library / net/mail

mail.AddressParser

Configure address parsing with an optional MIME word decoder for additional character sets. Expected stdout: 'café\n'.

Formal Syntax & Structure

go syntaxgo
type AddressParser struct {  WordDecoder *mime.WordDecoder}

Working Example

Example Snippetgo
package main
import (  "fmt"  "mime"  "net/mail")
func main() {  p := mail.AddressParser{WordDecoder: &mime.WordDecoder{}}  v := must(p.Parse("=?UTF-8?Q?caf=C3=A9?= <ada@example.invalid>"))  fmt.Println(v.Name)}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference