Formatter is analogous to fmt.Formatter.
type Formatter interface { Format(state State, verb rune) }
A Parser parses a format string. The result from the parse are set in the struct fields.
type Parser struct { Verb rune WidthPresent bool PrecPresent bool Minus bool Plus bool Sharp bool Space bool Zero bool // For the formats %+v %#v, we set the plusV/sharpV flags // and clear the plus/sharp flags since %+v and %#v are in effect // different, flagless formats set at the top level. PlusV bool SharpV bool HasIndex bool Width int Prec int // precision // retain arguments across calls. Args []interface{} // retain current argument number across calls ArgNum int // reordered records whether the format string used argument reordering. Reordered bool Status Status // contains filtered or unexported fields }
func (p *Parser) ClearFlags()
ClearFlags reset the parser to default behavior.
func (p *Parser) Reset(args []interface{})
Reset initializes a parser to scan format strings for the given args.
func (p *Parser) Scan() bool
Scan scans the next part of the format string and sets the status to indicate whether it scanned a string literal, substitution or error.
func (p *Parser) SetFormat(format string)
SetFormat sets a new format string to parse. It does not reset the argument count.
func (p *Parser) Text() string
Text returns the part of the format string that was parsed by the last call to Scan. It returns the original substitution clause if the current scan parsed a substitution.
State represents the printer state passed to custom formatters. It provides access to the fmt.State interface and the sentence and language-related context.
type State interface { fmt.State // Language reports the requested language in which to render a message. Language() language.Tag }
Status indicates the result type of a call to Scan.
type Status int
const ( StatusText Status = iota StatusSubstitution StatusBadWidthSubstitution StatusBadPrecSubstitution StatusNoVerb StatusBadArgNum StatusMissingArg )