Documentation
¶
Index ¶
- Constants
- func GetPathByRelativePath(relativeFilePath, inheritedPath string) string
- type INI
- func (ini *INI) Delete(section, key string)
- func (ini *INI) Get(key string) (string, bool)
- func (ini *INI) GetAll() SectionMap
- func (ini *INI) GetBool(key string) (bool, bool)
- func (ini *INI) GetFloat(key string) (float64, bool)
- func (ini *INI) GetInt(key string) (int, bool)
- func (ini *INI) GetKvmap(section string) (kvmap Kvmap, ok bool)
- func (ini *INI) GetSections() []string
- func (ini *INI) Merge(from *INI, override bool)
- func (ini *INI) Parse(data []byte, lineSep, kvSep string) error
- func (ini *INI) ParseFile(filename string) error
- func (ini *INI) ParseFrom(r io.Reader, lineSep, kvSep string) error
- func (ini *INI) Reset()
- func (ini *INI) SectionGet(section, key string) (value string, ok bool)
- func (ini *INI) SectionGetBool(section, key string) (bool, bool)
- func (ini *INI) SectionGetFloat(section, key string) (float64, bool)
- func (ini *INI) SectionGetInt(section, key string) (int, bool)
- func (ini *INI) SectionSet(section, key, value string)
- func (ini *INI) SectionSetBool(section, key string, value bool)
- func (ini *INI) SectionSetFloat(section, key string, value float64)
- func (ini *INI) SectionSetInt(section, key string, value int)
- func (ini *INI) Set(key, value string)
- func (ini *INI) SetBool(key string, value bool)
- func (ini *INI) SetFloat(key string, value float64)
- func (ini *INI) SetInt(key string, value int)
- func (ini *INI) SetParseSection(parseSection bool)
- func (ini *INI) SetSkipCommits(skipCommits bool)
- func (ini *INI) SetTrimQuotes(v bool)
- func (ini *INI) Write(w io.Writer) error
- type Kvmap
- type SectionMap
Constants ¶
const ( DefaultSection = "" DefaultLineSeparator = "\n" DefaultKeyValueSeparator = "=" )
const (
InheritedFrom = "inherited_from" // The key of the INI path which will be inherited from
)
Variables ¶
This section is empty.
Functions ¶
func GetPathByRelativePath ¶
GetPathByRelativePath gets the real path according to the relative file path e.g. :
relativeFilePath = /home/goini/conf/common.conf inheritedPath = app.conf
and then the GetPathByRelativePath(relativeFilePath, inheritedPath) will return /home/goini/conf/app.conf
Types ¶
type INI ¶
type INI struct {
// contains filtered or unexported fields
}
func LoadInheritedINI ¶
LoadInheritedINI loads an INI file which inherits from another INI e.g:
The common.ini has contents: project=common ip=192.168.0.1 And the project.ini has contents: project=ppp combo=ppp inherited_from=common.ini The project.ini has the same configure as below : project=ppp combo=ppp ip=192.168.0.1
func (*INI) Get ¶
Get looks up a value for a key in the default section and returns that value, along with a boolean result similar to a map lookup.
func (*INI) GetAll ¶
func (ini *INI) GetAll() SectionMap
GetAll gets the section map and its key/value pairs.
func (*INI) GetBool ¶
GetBool returns the boolean value represented by the string. It accepts "1", "t", "T", "true", "TRUE", "True", "on", "ON", "On", "yes", "YES", "Yes" as true and "0", "f", "F", "false", "FALSE", "False", "off", "OFF", "Off", "no", "NO", "No" as false Any other value returns false.
func (*INI) GetKvmap ¶
GetKvmap gets all keys under section as a Kvmap (map[string]string). The first return value will get the value that corresponds to the key (or the map’s value type’s zero value if the key isn’t present), and the second will get true(or false if the key isn’t present).
func (*INI) GetSections ¶
Added by UndeadIndustries to simply get sections.
func (*INI) Merge ¶
Merge merges the data in another INI (from) to this INI (ini), and from INI will not be changed
func (*INI) Parse ¶
Parse parses the data to store the data in the INI A successful call returns err == nil
func (*INI) ParseFile ¶
ParseFile reads the INI file named by filename and parse the contents to store the data in the INI A successful call returns err == nil
func (*INI) ParseFrom ¶
ParseFrom reads all the data from reader r and parse the contents to store the data in the INI A successful call returns err == nil
func (*INI) SectionGet ¶
SectionGet looks up a value for a key in a section and returns that value, along with a boolean result similar to a map lookup.
func (*INI) SectionGetBool ¶
SectionGetBool gets a value as bool. See GetBool for more detail
func (*INI) SectionGetFloat ¶
SectionGetFloat gets value as float64
func (*INI) SectionGetInt ¶
SectionGetInt gets value as int
func (*INI) SectionSet ¶
SectionSet stores the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) SectionSetBool ¶
SectionSetBool stores the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) SectionSetFloat ¶
SectionSetFloat stores the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) SectionSetInt ¶
SectionSetInt stores the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) Set ¶
Set stores the key/value pair to the default section of this INI, creating it if it wasn't already present.
func (*INI) SetBool ¶
SetBool stores the key/value pair to the default section of this INI, creating it if it wasn't already present.
func (*INI) SetFloat ¶
SetFloat stores the key/value pair to the default section of this INI, creating it if it wasn't already present.
func (*INI) SetInt ¶
SetInt store the key/value pair to the default section of this INI, creating it if it wasn't already present.
func (*INI) SetParseSection ¶
SetParseSection sets INI.parseSection whether to process the INI section when parsing
func (*INI) SetSkipCommits ¶
SetSkipCommits sets INI.skipCommits whether to skip commits when parsing
func (*INI) SetTrimQuotes ¶
SetTrimQuotes sets INI.trimQuotes whether to trim quotation marks of the value when parsing