ini

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2024 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntriesMap

type EntriesMap = cog.LinkedHashMap[string, *EntryList]

type Entry

type Entry struct {
	Value    string
	Comments []string
}

Entry ini entry

type EntryList

type EntryList = cog.LinkedList[*Entry]

type Ini

type Ini struct {
	EOL string // End of Line
	// contains filtered or unexported fields
}

Ini INI file reader / writer

func NewIni

func NewIni() *Ini

NewIni create a Ini

func (*Ini) Add

func (ini *Ini) Add(sec, key, value string, comments ...string) *Entry

Add add a key/value entry to the section sec

func (*Ini) AddSection

func (ini *Ini) AddSection(section *Section)

AddSection add a section to INI, overwrite existing section

func (*Ini) Clear

func (ini *Ini) Clear()

Clear clears the ini

func (*Ini) Copy

func (ini *Ini) Copy(src *Ini)

Copy copy section/entries from src ini, overwrite existing entries

func (*Ini) Get

func (ini *Ini) Get(sec, key string) string

Get get a value of the key from the section sec

func (*Ini) GetBool

func (ini *Ini) GetBool(sec, key string, defs ...bool) bool

GetBool get a bool value of the key from the section sec if not found or convert error, returns the default defs[0] bool value

func (*Ini) GetDuration

func (ini *Ini) GetDuration(sec, key string, defs ...time.Duration) time.Duration

GetDuration get a time.Duration value of the key from the section sec if not found or convert error, returns the default defs[0] Duration value

func (*Ini) GetFloat

func (ini *Ini) GetFloat(sec, key string, defs ...float64) float64

GetFloat get a float value of the key from the section sec if not found or convert error, returns the default defs[0] float value

func (*Ini) GetInt

func (ini *Ini) GetInt(sec, key string, defs ...int) int

GetInt get a int value of the key from the section sec if not found or convert error, returns the default defs[0] int value

func (*Ini) GetInt64

func (ini *Ini) GetInt64(sec, key string, defs ...int64) int64

GetInt64 get a int64 value of the key from the section sec if not found or convert error, returns the default defs[0] int64 value

func (*Ini) GetSection

func (ini *Ini) GetSection(name string) *Section

GetSection return a section with the specified name or nil if section not exists

func (*Ini) GetSize

func (ini *Ini) GetSize(sec, key string, defs ...int64) int64

GetSize get a int64 size value of the key from the section sec if not found or convert error, returns the default defs[0] int value

func (*Ini) GetString

func (ini *Ini) GetString(sec, key string, defs ...string) string

GetString get a string value of the key from the section sec if not found, returns the default defs[0] string value

func (*Ini) IsEmpty

func (ini *Ini) IsEmpty() bool

IsEmpty returns true if the Ini has no entry

func (*Ini) LoadData

func (ini *Ini) LoadData(r io.Reader, multiple ...bool) (err error)

LoadData load INI from io.Reader if multiple = true, allow multiple entry with same key

func (*Ini) LoadFile

func (ini *Ini) LoadFile(path string, multiple ...bool) error

LoadFile load INI from file if multiple = true, allow multiple entry with same key

func (*Ini) LoadFileFS

func (ini *Ini) LoadFileFS(fsys fs.FS, path string, multiple ...bool) error

LoadFileFS load INI from file if multiple = true, allow multiple entry with same key

func (*Ini) Map

func (ini *Ini) Map() map[string]map[string]any

Map convert ini to map[string]map[string]any

func (*Ini) Merge

func (ini *Ini) Merge(src *Ini)

Merge merge entries from src ini, existing section/entries will be merged

func (*Ini) NewSection

func (ini *Ini) NewSection(name string, comments ...string) *Section

NewSection create a section to INI, overwrite existing section

func (*Ini) RemoveSection

func (ini *Ini) RemoveSection(name string) (sec *Section)

RemoveSection remove a section from INI

func (*Ini) Section

func (ini *Ini) Section(name string) (sec *Section)

Section return a section with the specified name. if the section does not exists, create and add it to ini.

func (*Ini) SectionNames

func (ini *Ini) SectionNames() []string

SectionNames returns the section array

func (*Ini) Sections

func (ini *Ini) Sections() []*Section

Sections returns the section array

func (*Ini) Set

func (ini *Ini) Set(sec, key, value string, comments ...string) *Entry

Set set a key/value entry to the section sec

func (*Ini) String

func (ini *Ini) String() string

String write INI to the string

func (*Ini) StringMap

func (ini *Ini) StringMap() map[string]map[string]string

StringMap convert ini to map[string]map[string]string

func (*Ini) StringsMap

func (ini *Ini) StringsMap() map[string]map[string][]string

StringsMap convert ini to map[string]map[string][]string

func (*Ini) WriteData

func (ini *Ini) WriteData(w io.Writer) (err error)

WriteData write INI to io.Writer

func (*Ini) WriteFile

func (ini *Ini) WriteFile(path string) error

WriteFile write INI to the file

type Section

type Section struct {
	// contains filtered or unexported fields
}

Section ini section

func NewSection

func NewSection(name string, comments ...string) *Section

NewSection create a INI section

func (*Section) Add

func (sec *Section) Add(key string, value string, comments ...string) *Entry

Add add a key/value entry to the section

func (*Section) Clear

func (sec *Section) Clear()

Clear clear the entries and comments

func (*Section) Comments

func (sec *Section) Comments() []string

Comments return the section's comment string array

func (*Section) Copy

func (sec *Section) Copy(src *Section)

Copy copy entries from src section, overwrite existing entries

func (*Section) Delete

func (sec *Section) Delete(key string)

Delete delete entries with key form the section

func (*Section) Get

func (sec *Section) Get(key string) string

Get get a value of the key from the section

func (*Section) GetBool

func (sec *Section) GetBool(key string, defs ...bool) bool

GetBool get a bool value of the key from the section if not found or convert error, returns the default defs[0] bool value

func (*Section) GetDuration

func (sec *Section) GetDuration(key string, defs ...time.Duration) time.Duration

GetDuration get a time.Duration value of the key from the section if not found or convert error, returns the default defs[0] Duration value

func (*Section) GetEntries

func (sec *Section) GetEntries(key string) []*Entry

GetEntries get the key's entries from the section

func (*Section) GetEntry

func (sec *Section) GetEntry(key string) *Entry

GetEntry get the key's entry from the section

func (*Section) GetFloat

func (sec *Section) GetFloat(key string, defs ...float64) float64

GetFloat get a float value of the key from the section if not found or convert error, returns the default defs[0] float value

func (*Section) GetInt

func (sec *Section) GetInt(key string, defs ...int) int

GetInt get a int value of the key from the section if not found or convert error, returns the default defs[0] int value

func (*Section) GetInt64

func (sec *Section) GetInt64(key string, defs ...int64) int64

GetInt64 get a int64 value of the key from the section if not found or convert error, returns the default defs[0] int64 value

func (*Section) GetSize

func (sec *Section) GetSize(key string, defs ...int64) int64

GetSize get a int64 size value of the key from the section if not found or convert error, returns the default defs[0] int value

func (*Section) GetString

func (sec *Section) GetString(key string, defs ...string) string

GetString get a string value of the key from the section if not found, returns the default defs[0] string value

func (*Section) GetValues

func (sec *Section) GetValues(key string) []string

GetValues get the key's values from the section

func (*Section) Keys

func (sec *Section) Keys() []string

Keys return the section's key string array

func (*Section) Map

func (sec *Section) Map() map[string]any

Map return the section's entries key.(string)/value.(any) map

func (*Section) Merge

func (sec *Section) Merge(src *Section)

Merge merge entries from src section, existing entries will be merged

func (*Section) Name

func (sec *Section) Name() string

Name return the section's name

func (*Section) Remove

func (sec *Section) Remove(key string, value string) (e *Entry)

Remove remove a key/value entry from the section

func (*Section) Set

func (sec *Section) Set(key string, value string, comments ...string) *Entry

Set set a key/value entry to the section

func (*Section) String

func (sec *Section) String() string

String write section to string

func (*Section) StringMap

func (sec *Section) StringMap() map[string]string

StringMap return the section's entries key.(string)/value.(string) map

func (*Section) StringsMap

func (sec *Section) StringsMap() map[string][]string

StringsMap return the section's entries key.(string)/value.([]string) map

func (*Section) Write

func (sec *Section) Write(bw *bufio.Writer, eol string) error

Write output section to the writer

type Sections

type Sections = cog.LinkedHashMap[string, *Section]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL