package ini

Import Path
	gopkg.in/ini.v1 (on go.dev)

Dependency Relation
	imports 15 packages, and imported by one package

Involved Source Files data_source.go deprecated.go error.go file.go helper.go Package ini provides INI file read and write functionality in Go. key.go parser.go section.go struct.go
Package-Level Type Names (total 16, in which 10 are exported)
/* sort exporteds by: | */
DebugFunc is the type of function called to log parse events.
ErrDelimiterNotFound indicates the error type of no delimiter is found which there should be one. Line string ( T) Error() string T : error
File represents a combination of one or more INI files in memory. Should make things safe, but sometimes doesn't matter. NameMapper NameMapper ValueMapper ValueMapper Append appends one or more data sources and reloads automatically. ChildSections returns a list of child sections of given section name. DeleteSection deletes a section or all sections with given name. DeleteSectionWithIndex deletes a section with given name and index. GetSection returns section by given name. MapTo maps file to given struct. NewRawSection creates a new section with an unparseable body. NewSection creates a new section. NewSections creates a list of sections. ReflectFrom reflects file from given struct. Reload reloads and parses all data sources. SaveTo writes content to file system. SaveToIndent writes content to file system with given value indention. Section assumes named section exists and returns a zero-value when not. SectionStrings returns list of section names. SectionWithIndex assumes named section exists and returns a new section when not. Sections returns a list of Section stored in the current instance. SectionsByName returns all sections with given name. StrictMapTo maps file to given struct in strict mode, which returns all possible error including value parsing error. WriteTo writes file content into io.Writer. WriteToIndent writes content into io.Writer with given indention. If PrettyFormat has been set to be true, it will align "=" sign with spaces under each section. *T : io.WriterTo func Empty(opts ...LoadOptions) *File func InsensitiveLoad(source interface{}, others ...interface{}) (*File, error) func Load(source interface{}, others ...interface{}) (*File, error) func LoadSources(opts LoadOptions, source interface{}, others ...interface{}) (_ *File, err error) func LooseLoad(source interface{}, others ...interface{}) (*File, error) func ShadowLoad(source interface{}, others ...interface{}) (*File, error) func ReflectFrom(cfg *File, v interface{}) error func ReflectFromWithMapper(cfg *File, v interface{}, mapper NameMapper) error func StructReflector.ReflectINIStruct(*File) error
Key represents a key under a section. Comment string AddNestedValue adds a nested value to the key. AddShadow adds a new shadow key to itself. Bool returns bool type value. Bools returns list of bool divided by given delimiter. Any invalid input will be treated as zero value. Duration returns time.Duration type value. Float64 returns float64 type value. Float64s returns list of float64 divided by given delimiter. Any invalid input will be treated as zero value. In always returns value without error, it returns default value if error occurs or doesn't fit into candidates. InFloat64 always returns value without error, it returns default value if error occurs or doesn't fit into candidates. InInt always returns value without error, it returns default value if error occurs or doesn't fit into candidates. InInt64 always returns value without error, it returns default value if error occurs or doesn't fit into candidates. InTime always parses with RFC3339 format and returns value without error, it returns default value if error occurs or doesn't fit into candidates. InTimeFormat always parses with given format and returns value without error, it returns default value if error occurs or doesn't fit into candidates. InUint always returns value without error, it returns default value if error occurs or doesn't fit into candidates. InUint64 always returns value without error, it returns default value if error occurs or doesn't fit into candidates. Int returns int type value. Int64 returns int64 type value. Int64s returns list of int64 divided by given delimiter. Any invalid input will be treated as zero value. Ints returns list of int divided by given delimiter. Any invalid input will be treated as zero value. MustBool always returns value without error, it returns false if error occurs. MustDuration always returns value without error, it returns zero value if error occurs. MustFloat64 always returns value without error, it returns 0.0 if error occurs. MustInt always returns value without error, it returns 0 if error occurs. MustInt64 always returns value without error, it returns 0 if error occurs. MustString returns default value if key value is empty. MustTime always parses with RFC3339 format and returns value without error, it returns zero value if error occurs. MustTimeFormat always parses with given format and returns value without error, it returns zero value if error occurs. MustUint always returns value without error, it returns 0 if error occurs. MustUint64 always returns value without error, it returns 0 if error occurs. Name returns name of key. NestedValues returns nested values stored in the key. It is possible returned value is nil if no nested values stored in the key. RangeFloat64 checks if value is in given range inclusively, and returns default value if it's not. RangeInt checks if value is in given range inclusively, and returns default value if it's not. RangeInt64 checks if value is in given range inclusively, and returns default value if it's not. RangeTime checks if value with RFC3339 format is in given range inclusively, and returns default value if it's not. RangeTimeFormat checks if value with given format is in given range inclusively, and returns default value if it's not. SetValue changes key value. StrictBools returns list of bool divided by given delimiter or error on first invalid input. StrictFloat64s returns list of float64 divided by given delimiter or error on first invalid input. StrictInt64s returns list of int64 divided by given delimiter or error on first invalid input. StrictInts returns list of int divided by given delimiter or error on first invalid input. StrictTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter or error on first invalid input. StrictTimesFormat parses with given format and returns list of time.Time divided by given delimiter or error on first invalid input. StrictUint64s returns list of uint64 divided by given delimiter or error on first invalid input. StrictUints returns list of uint divided by given delimiter or error on first invalid input. String returns string representation of value. Strings returns list of string divided by given delimiter. StringsWithShadows returns list of string divided by given delimiter. Shadows will also be appended if any. Time parses with RFC3339 format and returns time.Time type value. TimeFormat parses with given format and returns time.Time type value. Times parses with RFC3339 format and returns list of time.Time divided by given delimiter. Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). TimesFormat parses with given format and returns list of time.Time divided by given delimiter. Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). Uint returns uint type valued. Uint64 returns uint64 type value. Uint64s returns list of uint64 divided by given delimiter. Any invalid input will be treated as zero value. Uints returns list of uint divided by given delimiter. Any invalid input will be treated as zero value. ValidBools returns list of bool divided by given delimiter. If some value is not 64-bit unsigned integer, then it will not be included to result list. ValidFloat64s returns list of float64 divided by given delimiter. If some value is not float, then it will not be included to result list. ValidInt64s returns list of int64 divided by given delimiter. If some value is not 64-bit integer, then it will not be included to result list. ValidInts returns list of int divided by given delimiter. If some value is not integer, then it will not be included to result list. ValidTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter. ValidTimesFormat parses with given format and returns list of time.Time divided by given delimiter. ValidUint64s returns list of uint64 divided by given delimiter. If some value is not 64-bit unsigned integer, then it will not be included to result list. ValidUints returns list of uint divided by given delimiter. If some value is not unsigned integer, then it will not be included to result list. Validate accepts a validate function which can return modifed result as key value. Value returns raw value of key for performance purpose. ValueWithShadows returns raw values of key and its shadows if any. *T : fmt.Stringer func (*Section).GetKey(name string) (*Key, error) func (*Section).Key(name string) *Key func (*Section).Keys() []*Key func (*Section).NewBooleanKey(name string) (*Key, error) func (*Section).NewKey(name, val string) (*Key, error) func (*Section).ParentKeys() []*Key
LoadOptions contains all customized options used for load data source(s). AllowBooleanKeys indicates whether to allow boolean type keys or treat as value is missing. This type of keys are mostly used in my.cnf. AllowNestedValues indicates whether to allow AWS-like nested values. Docs: http://docs.aws.amazon.com/cli/latest/topic/config-vars.html#nested-values AllowNonUniqueSections indicates whether to allow sections with the same name multiple times. AllowPythonMultilineValues indicates whether to allow Python-like multi-line values. Docs: https://docs.python.org/3/library/configparser.html#supported-ini-file-structure Relevant quote: Values can also span multiple lines, as long as they are indented deeper than the first line of the value. AllowShadows indicates whether to keep track of keys with same name under same section. ChildSectionDelimiter is the delimiter that is used to separate child sections. By default, it is ".". DebugFunc is called to collect debug information (currently only useful to debug parsing Python-style multiline values). IgnoreContinuation indicates whether to ignore continuation lines while parsing. IgnoreInlineComment indicates whether to ignore comments at the end of value and treat it as part of value. Insensitive indicates whether the parser forces all section and key names to lowercase. InsensitiveKeys indicates whether the parser forces all key names to lowercase. InsensitiveSections indicates whether the parser forces all section to lowercase. KeyValueDelimiterOnWrite is the delimiter that are used to separate key and value output. By default, it is "=". KeyValueDelimiters is the sequence of delimiters that are used to separate key and value. By default, it is "=:". Loose indicates whether the parser should ignore nonexistent files or return error. PreserveSurroundedQuote indicates whether to preserve surrounded quote (single and double quotes). ReaderBufferSize is the buffer size of the reader in bytes. ShortCircuit indicates whether to ignore other configuration sources after loaded the first available configuration source. SkipUnrecognizableLines indicates whether to skip unrecognizable lines that do not conform to key/value pairs. SpaceBeforeInlineComment indicates whether to allow comment symbols (\# and \;) inside value. Docs: https://docs.python.org/2/library/configparser.html Quote: Comments may appear on their own in an otherwise empty line, or may be entered in lines holding values or section names. In the latter case, they need to be preceded by a whitespace character to be recognized as a comment. UnescapeValueCommentSymbols indicates to unescape comment symbols (\# and \;) inside value to regular format when value is NOT surrounded by any quotes. Note: UNSTABLE, behavior might change to only unescape inside double quotes but may noy necessary at all. UnescapeValueDoubleQuotes indicates whether to unescape double quotes inside value to regular format when value is surrounded by double quotes, e.g. key="a \"value\"" => key=a "value" UnparseableSections stores a list of blocks that are allowed with raw content which do not otherwise conform to key/value pairs. Specify the names of those blocks here. func Empty(opts ...LoadOptions) *File func LoadSources(opts LoadOptions, source interface{}, others ...interface{}) (_ *File, err error) func github.com/spf13/viper.IniLoadOptions(in LoadOptions) viper.Option
NameMapper represents a ini tag name mapper. func MapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error func ReflectFromWithMapper(cfg *File, v interface{}, mapper NameMapper) error func StrictMapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error var AllCapsUnderscore var SnackCase var TitleUnderscore
Section represents a config section. Comment string Body returns rawBody of Section if the section was marked as unparseable. It still follows the other rules of the INI format surrounding leading/trailing whitespace. ChildSections returns a list of child sections of current section. For example, "[parent.child1]" and "[parent.child12]" are child sections of section "[parent]". DeleteKey deletes a key from section. GetKey returns key in section by given name. HasKey returns true if section contains a key with given name. HasValue returns true if section contains given raw value. Deprecated: Use "HasKey" instead. Key assumes named Key exists in section and returns a zero-value when not. KeyStrings returns list of key names of section. Keys returns list of keys of section. KeysHash returns keys hash consisting of names and values. MapTo maps section to given struct. Name returns name of Section. NewBooleanKey creates a new boolean type key to given section. NewKey creates a new key to given section. ParentKeys returns list of keys of parent section. ReflectFrom reflects section from given struct. It overwrites existing ones. SetBody updates body content only if section is raw. StrictMapTo maps section to given struct in strict mode, which returns all possible error including value parsing error. func (*File).ChildSections(name string) []*Section func (*File).GetSection(name string) (*Section, error) func (*File).NewRawSection(name, body string) (*Section, error) func (*File).NewSection(name string) (*Section, error) func (*File).Section(name string) *Section func (*File).Sections() []*Section func (*File).SectionsByName(name string) ([]*Section, error) func (*File).SectionWithIndex(name string, index int) *Section func (*Section).ChildSections() []*Section
StructReflector is the interface implemented by struct types that can extract themselves into INI objects. ( T) ReflectINIStruct(*File) error
ValueMapper represents a mapping function for values, e.g. os.ExpandEnv
Package-Level Functions (total 32, in which 13 are exported)
Empty returns an empty file object.
InsensitiveLoad has exactly same functionality as Load function except it forces all section and key names to be lowercased.
IsErrDelimiterNotFound returns true if the given error is an instance of ErrDelimiterNotFound.
Load loads and parses from INI data sources. Arguments can be mixed of file name with string type, or raw data in []byte. It will return error if list contains nonexistent files.
LoadSources allows caller to apply customized options for loading from data source(s).
LooseLoad has exactly same functionality as Load function except it ignores nonexistent files instead of returning error.
MapTo maps data sources to given struct.
MapToWithMapper maps data sources to given struct with name mapper.
ReflectFrom reflects data sources from given struct.
ReflectFromWithMapper reflects data sources from given struct with name mapper.
ShadowLoad has exactly same functionality as Load function except it allows have shadow keys.
StrictMapTo maps data sources to given struct in strict mode, which returns all possible error including value parsing error.
StrictMapToWithMapper maps data sources to given struct with name mapper in strict mode, which returns all possible error including value parsing error.
Package-Level Variables (total 14, in which 10 are exported)
Deprecated: AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE.
DefaultFormatLeft places custom spaces on the left when PrettyFormat and PrettyEqual are both disabled.
DefaultFormatRight places custom spaces on the right when PrettyFormat and PrettyEqual are both disabled.
DefaultHeader explicitly writes default section header.
LineBreak is the delimiter to determine or compose a new line. This variable will be changed to "\r\n" automatically on Windows at package init time.
PrettyEqual places spaces around "=" sign even when PrettyFormat is false.
PrettyFormat indicates whether to align "=" sign with spaces to produce pretty output or reduce all possible spaces for compact format.
PrettySection indicates whether to put a line between sections.
SnackCase converts to format SNACK_CASE.
TitleUnderscore converts to format title_underscore.
Package-Level Constants (total 4, in which 2 are exported)
Deprecated: Use "DefaultSection" instead.
DefaultSection is the name of default section. You can use this constant or the string literal. In most of cases, an empty string is all you need to access the section.