Documentation
¶
Index ¶
- func AddSection(sec *Section)
- func Clear()
- func Copy(src *Ini)
- func Get(sec, key string) string
- func GetBool(sec, key string, defs ...bool) bool
- func GetDuration(sec, key string, defs ...time.Duration) time.Duration
- func GetFloat(sec, key string, defs ...float64) float64
- func GetInt(sec, key string, defs ...int) int
- func GetInt64(sec, key string, defs ...int64) int64
- func GetSize(sec, key string, defs ...int64) int64
- func GetString(sec, key string, defs ...string) string
- func IsEmpty() bool
- func LoadData(r io.Reader, multiple ...bool) error
- func LoadFile(path string, multiple ...bool) error
- func LoadFileFS(fsys fs.FS, path string, multiple ...bool) error
- func Map() map[string]map[string]any
- func Merge(src *Ini)
- func SectionNames() []string
- func SetDefault(ini *Ini)
- func String() string
- func StringMap() map[string]map[string]string
- func StringsMap() map[string]map[string][]string
- func WriteData(w io.Writer) error
- func WriteFile(path string) error
- type EntriesMap
- type Entry
- type EntryList
- type Ini
- func (ini *Ini) Add(sec, key, value string, comments ...string) *Entry
- func (ini *Ini) AddSection(section *Section)
- func (ini *Ini) Clear()
- func (ini *Ini) Copy(src *Ini)
- func (ini *Ini) Get(sec, key string) string
- func (ini *Ini) GetBool(sec, key string, defs ...bool) bool
- func (ini *Ini) GetDuration(sec, key string, defs ...time.Duration) time.Duration
- func (ini *Ini) GetEntry(sec, key string) *Entry
- func (ini *Ini) GetFloat(sec, key string, defs ...float64) float64
- func (ini *Ini) GetInt(sec, key string, defs ...int) int
- func (ini *Ini) GetInt64(sec, key string, defs ...int64) int64
- func (ini *Ini) GetSection(name string) *Section
- func (ini *Ini) GetSize(sec, key string, defs ...int64) int64
- func (ini *Ini) GetString(sec, key string, defs ...string) string
- func (ini *Ini) IsEmpty() bool
- func (ini *Ini) LoadData(r io.Reader, multiple ...bool) (err error)
- func (ini *Ini) LoadFile(path string, multiple ...bool) error
- func (ini *Ini) LoadFileFS(fsys fs.FS, path string, multiple ...bool) error
- func (ini *Ini) Map() map[string]map[string]any
- func (ini *Ini) Merge(src *Ini)
- func (ini *Ini) NewSection(name string, comments ...string) *Section
- func (ini *Ini) RemoveSection(name string) (sec *Section)
- func (ini *Ini) Section(name string) (sec *Section)
- func (ini *Ini) SectionNames() []string
- func (ini *Ini) Sections() []*Section
- func (ini *Ini) Set(sec, key, value string, comments ...string) *Entry
- func (ini *Ini) String() string
- func (ini *Ini) StringMap() map[string]map[string]string
- func (ini *Ini) StringsMap() map[string]map[string][]string
- func (ini *Ini) WriteData(w io.Writer) (err error)
- func (ini *Ini) WriteFile(path string) error
- type Section
- func (sec *Section) Add(key string, value string, comments ...string) *Entry
- func (sec *Section) Clear()
- func (sec *Section) Comments() []string
- func (sec *Section) Copy(src *Section)
- func (sec *Section) Delete(key string)
- func (sec *Section) Get(key string) string
- func (sec *Section) GetBool(key string, defs ...bool) bool
- func (sec *Section) GetDuration(key string, defs ...time.Duration) time.Duration
- func (sec *Section) GetEntries(key string) []*Entry
- func (sec *Section) GetEntry(key string) *Entry
- func (sec *Section) GetFloat(key string, defs ...float64) float64
- func (sec *Section) GetInt(key string, defs ...int) int
- func (sec *Section) GetInt64(key string, defs ...int64) int64
- func (sec *Section) GetSize(key string, defs ...int64) int64
- func (sec *Section) GetString(key string, defs ...string) string
- func (sec *Section) GetValues(key string) []string
- func (sec *Section) Keys() []string
- func (sec *Section) Map() map[string]any
- func (sec *Section) Merge(src *Section)
- func (sec *Section) Name() string
- func (sec *Section) Remove(key string, value string) (e *Entry)
- func (sec *Section) Set(key string, value string, comments ...string) *Entry
- func (sec *Section) String() string
- func (sec *Section) StringMap() map[string]string
- func (sec *Section) StringsMap() map[string][]string
- func (sec *Section) Write(w io.Writer, eol string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSection ¶ added in v1.0.27
func AddSection(sec *Section)
AddSection add a section to INI, overwrite existing section
func Copy ¶ added in v1.0.27
func Copy(src *Ini)
Copy copy section/entries from src ini, overwrite existing entries
func GetBool ¶ added in v1.0.27
GetBool get a bool value of the key from the section sec if not found or convert error, returns the first non-false value from defs.
func GetDuration ¶ added in v1.0.27
GetDuration get a time.Duration value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func GetFloat ¶ added in v1.0.27
GetFloat get a float value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func GetInt ¶ added in v1.0.27
GetInt get a int value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func GetInt64 ¶ added in v1.0.27
GetInt64 get a int64 value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func GetSize ¶ added in v1.0.27
GetSize get a int64 size value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func GetString ¶ added in v1.0.27
GetString get a string value of the key from the section sec if not found, returns the default defs[0] string value
func LoadData ¶ added in v1.0.27
LoadData load INI from io.Reader if multiple = true, allow multiple entry with same key
func LoadFile ¶ added in v1.0.27
LoadFile load INI from file if multiple = true, allow multiple entry with same key
func LoadFileFS ¶ added in v1.0.27
LoadFileFS load INI from file if multiple = true, allow multiple entry with same key
func Merge ¶ added in v1.0.27
func Merge(src *Ini)
Merge merge entries from src ini, existing section/entries will be merged
func SectionNames ¶ added in v1.0.27
func SectionNames() []string
SectionNames returns the section array
func SetDefault ¶ added in v1.0.27
func SetDefault(ini *Ini)
SetDefault set the default Ini instance used by the package-level functions.
func StringsMap ¶ added in v1.0.27
StringsMap convert ini to map[string]map[string][]string
Types ¶
type EntriesMap ¶
type EntriesMap = linkedhashmap.LinkedHashMap[string, *EntryList]
type Entry ¶
Entry ini entry
type EntryList ¶
type EntryList = linkedlist.LinkedList[*Entry]
type Ini ¶
type Ini struct {
EOL string // End of Line
// contains filtered or unexported fields
}
Ini INI file reader / writer
func Default ¶ added in v1.0.27
func Default() *Ini
Default returns the default Ini instance used by the package-level functions.
func (*Ini) AddSection ¶
AddSection add a section to INI, overwrite existing section
func (*Ini) GetBool ¶
GetBool get a bool value of the key from the section sec if not found or convert error, returns the first non-false value from defs.
func (*Ini) GetDuration ¶
GetDuration get a time.Duration value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func (*Ini) GetFloat ¶
GetFloat get a float value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func (*Ini) GetInt ¶
GetInt get a int value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func (*Ini) GetInt64 ¶
GetInt64 get a int64 value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func (*Ini) GetSection ¶
GetSection return a section with the specified name or nil if section not exists
func (*Ini) GetSize ¶
GetSize get a int64 size value of the key from the section sec if not found or convert error, returns the first non-zero value from defs.
func (*Ini) GetString ¶
GetString get a string value of the key from the section sec if not found, returns the first non-empty string value from defs.
func (*Ini) LoadData ¶
LoadData load INI from io.Reader if multiple = true, allow multiple entry with same key
func (*Ini) LoadFile ¶
LoadFile load INI from file if multiple = true, allow multiple entry with same key
func (*Ini) LoadFileFS ¶
LoadFileFS load INI from file if multiple = true, allow multiple entry with same key
func (*Ini) NewSection ¶
NewSection create a section to INI, overwrite existing section
func (*Ini) RemoveSection ¶
RemoveSection remove a section from INI
func (*Ini) Section ¶
Section return a section with the specified name. if the section does not exists, create and add it to ini.
func (*Ini) SectionNames ¶
SectionNames returns the section array
func (*Ini) StringsMap ¶
StringsMap convert ini to map[string]map[string][]string
type Section ¶
type Section struct {
// contains filtered or unexported fields
}
Section ini section
func GetSection ¶ added in v1.0.27
GetSection return a section with the specified name or nil if section not exists
func NewSection ¶
NewSection create a section to INI, overwrite existing section
func RemoveSection ¶ added in v1.0.27
RemoveSection remove a section from INI
func (*Section) GetBool ¶
GetBool get a bool value of the key from the section if not found or convert error, returns the first non-false value from defs.
func (*Section) GetDuration ¶
GetDuration get a time.Duration value of the key from the section. if not found or convert error, returns the first non-zero value from defs.
func (*Section) GetEntries ¶
GetEntries get the key's entries from the section
func (*Section) GetFloat ¶
GetFloat get a float value of the key from the section if not found or convert error, returns the first non-zero value from defs.
func (*Section) GetInt ¶
GetInt get a int value of the key from the section if not found or convert error, returns the first non-zero value from defs.
func (*Section) GetInt64 ¶
GetInt64 get a int64 value of the key from the section if not found or convert error, returns the first non-zero value from defs.
func (*Section) GetSize ¶
GetSize get a int64 size value of the key from the section if not found or convert error, returns the first non-zero value from defs.
func (*Section) GetString ¶
GetString get a string value of the key from the section if not found, returns the default defs[0] string value
func (*Section) StringsMap ¶
StringsMap return the section's entries key.(string)/value.([]string) map