ini

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const CR byte = 0x0D

CR is carriage return

View Source
const LF byte = 0x0A

LF is linefeed

Variables

This section is empty.

Functions

This section is empty.

Types

type Ini added in v1.0.2

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

Ini provides parsing and querying of INI format or simple name/value pairs such as a simple config file. A name/value pair format is just an INI with no sections, and properties can be queried using an empty section name.

func (*Ini) GetFlattenedKeys added in v1.0.2

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

GetFlattenedKeys returns all section names plus keys as one flattened array.

func (*Ini) GetKeys added in v1.0.2

func (ini *Ini) GetKeys(sectionName string) ([]string, error)

GetKeys returns the names of all keys in the specified section. Note, the returned key names are a snapshot in time, meaning other goroutines may change the contents of this INI as soon as the method returns.

func (*Ini) GetLastModified added in v1.0.2

func (ini *Ini) GetLastModified() time.Time

GetLastModified returns the last modified timestamp of the INI contents.

func (*Ini) GetProp added in v1.0.2

func (ini *Ini) GetProp(section string, key string) (val string, ok bool)

GetProp returns the value of the specified key in the named section.

func (*Ini) GetSectionNames added in v1.0.2

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

GetSectionNames returns the names of all sections in this INI. Note, the returned section names are a snapshot in time, meaning other goroutines may change the contents of this INI as soon as the method returns.

func (*Ini) LoadFromFile added in v1.0.2

func (ini *Ini) LoadFromFile(file *os.File) error

LoadFromFile loads an INI file from `os.File`.

func (*Ini) LoadFromFilespec added in v1.0.2

func (ini *Ini) LoadFromFilespec(filespec string) error

LoadFromFilespec loads an INI file from string containing path and filename.

func (*Ini) LoadFromReader added in v1.0.2

func (ini *Ini) LoadFromReader(reader io.Reader) error

LoadFromReader loads an INI file from an `io.Reader`.

func (*Ini) LoadFromString added in v1.0.2

func (ini *Ini) LoadFromString(s string) error

LoadFromString parses an INI from a string .

func (*Ini) ToMap added in v1.0.2

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

ToMap returns a flattened map of the section name plus keys mapped to values.

type Section

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

Section represents a section in an INI file. The section has a name, which is enclosed in square brackets in the file. The section also has an array of key/value pairs.

func (*Section) GetName

func (sec *Section) GetName() (name string)

GetName returns the name of the section.

func (*Section) GetProp

func (sec *Section) GetProp(key string) (val string, ok bool)

GetProp returns the value associated with the given key, or `ok=false` if key does not exist.

func (*Section) String

func (sec *Section) String() string

String returns a string representation of this section.

func (*Section) StringPropsOnly

func (sec *Section) StringPropsOnly() string

StringPropsOnly returns a string representation of this section without the section header.

Jump to

Keyboard shortcuts

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