Documentation
¶
Index ¶
- Constants
- Variables
- func Decode(r io.Reader, v interface{}) error
- func DecodeFile(file string, v interface{}) error
- func Dump(n Node)
- type Array
- type FormatRule
- func WithArray(format string) FormatRule
- func WithComment(with bool) FormatRule
- func WithEOL(format string) FormatRule
- func WithEmpty(with bool) FormatRule
- func WithFloat(format string, underscore int) FormatRule
- func WithInline(inline bool) FormatRule
- func WithNest(with bool) FormatRule
- func WithNumber(format string, underscore int) FormatRule
- func WithRaw(with bool) FormatRule
- func WithTab(tab int) FormatRule
- func WithTime(millis int, utc bool) FormatRule
- type Formatter
- type Literal
- type Node
- type Option
- type Parser
- type Position
- type ScanFunc
- type Scanner
- type Setter
- type Table
- type Token
Constants ¶
const ( TokEOF rune = -(iota) + 1 TokNL TokIdent TokString TokBasic TokLiteral TokBasicMulti TokLiteralMulti TokInteger TokFloat TokBool TokDate TokDatetime TokTime TokComment TokIllegal TokBegArray TokEndArray TokBegInline TokEndInline TokBegRegularTable TokEndRegularTable TokBegArrayTable TokEndArrayTable TokEqual TokDot TokComma TokNewline )
Variables ¶
var ErrUndefined = errors.New("undefined")
Functions ¶
func DecodeFile ¶
Decode a TOML document from the given file and writes the decode values into v. See Decode for more information about the decoding process.
Types ¶
type FormatRule ¶
func WithArray ¶
func WithArray(format string) FormatRule
Tell the formatter how to reformat arrays. By default, array with 0 or 1 element will always be written on the same line.
func WithComment ¶
func WithComment(with bool) FormatRule
Tell the formatter to keep comments from the original document when rewritting.
func WithEOL ¶
func WithEOL(format string) FormatRule
Tell the formatter which sequence of character to use to write the end of line.
func WithEmpty ¶
func WithEmpty(with bool) FormatRule
Tell the formatter to keep empty table when rewritting the document.
func WithFloat ¶
func WithFloat(format string, underscore int) FormatRule
Tell the formatter how to format floating point number and where to write an underscore to make it more readable (if needed)
func WithInline ¶
func WithInline(inline bool) FormatRule
Tell the formatter to reformat (array of) inline table(s) to (array of) regular table(s)
func WithNest ¶
func WithNest(with bool) FormatRule
Tell the formatter to indent nested sub table(s). If not set, all tables will be aligned.
func WithNumber ¶
func WithNumber(format string, underscore int) FormatRule
Tell the formatter which base to use to rewrite integer number and where to write an underscore to make it more readable (if needed)
func WithRaw ¶
func WithRaw(with bool) FormatRule
Tell the formatter to keep the format of the values as found in the original document. Using this option disables other options that format values.
func WithTab ¶
func WithTab(tab int) FormatRule
Set the character to indent lines. If tab is let to 0, tab character will be used otherwise one or multiple space(s)
func WithTime ¶
func WithTime(millis int, utc bool) FormatRule
Tell the formatter to use the precision of millisecond to use and if it is needed to convert offset datetime to UTC.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter is responsible to rewrite a TOML document according to the settings given by user.
func NewFormatter ¶
func NewFormatter(doc string, rules ...FormatRule) (*Formatter, error)
Create a new Formatter that will rewrite the TOML document doc according to the rules specify.