Documentation ¶
Overview ¶
Package format contains types for defining language-specific formatting of values.
This package is internal now, but will eventually be exposed after the API settles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶ added in v0.2.0
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 }
A Parser parses a format string. The result from the parse are set in the struct fields.
func (*Parser) ClearFlags ¶ added in v0.2.0
func (p *Parser) ClearFlags()
ClearFlags reset the parser to default behavior.
func (*Parser) Reset ¶ added in v0.2.0
func (p *Parser) Reset(args []interface{})
Reset initializes a parser to scan format strings for the given args.
func (*Parser) Scan ¶ added in v0.2.0
Scan scans the next part of the format string and sets the status to indicate whether it scanned a string literal, substitution or error.
type State ¶
type State interface { fmt.State // Language reports the requested language in which to render a message. Language() language.Tag }
State represents the printer state passed to custom formatters. It provides access to the fmt.State interface and the sentence and language-related context.