Documentation
¶
Overview ¶
package tinyini provides an extremely bare-bones library for parsing INI-like configuration files. For details, see the documentation for function Parse.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IniError ¶
type IniError struct {
Lineno int
// contains filtered or unexported fields
}
IniError describes a parsing error and provides its line number.
type Section ¶
Section contains all configuration key-values of a single bracketed section ("[example-section]"). All key-values may contain multiple values. The values are given in the order of occurrence.
type Sections ¶ added in v0.6.0
Sections is a convenience type over map[string]Sections.
func Parse ¶
Parse will produce a map of Section from an io.Reader. The caller should note that Parse returns a slice of errors in the order of occurrence, so the condition for success is len(errs) == 0.
Parse will parse as much as possible even when encountering errors, so result may contain something useful even if len(errs) > 0.
The global section is given with the empty section name "". Otherwise the section names will be whatever valid UTF-8 is found between the brackets '[' and ']'.
Parse ignores whitespace around section headers, keys, and non-quoted values. If the value should contain whitespace in its beginning or end, enclose the whole value in quotes (" value with whitespaces ").
Quotes may be contained in quoted values by escaping them with the backslash like \". Escaped quotes will be unquoted when parsing, but all other seemingly "escaped" values like \n are ignored and left verbatim.
All keys may contain multiple values. Their additional values are appended to their respective section in the order of appearance.
func (Sections) ForEach ¶ added in v0.6.0
ForEach is a convenience function for simple iteration over Sections. The passed callback is called with parsed values in the order of appearance. If the callback returns false, iteration is stopped. If a section-specific variable has been defined multiple times, each value will be passed on to the callback with separate invocations.