Documentation
¶
Index ¶
- Constants
- func GetPathByRelativePath(relativeFilePath, inheritedPath string) string
- type INI
- func (ini *INI) Delete(section, key string)
- func (ini *INI) Get(key string) (value string, ok bool)
- func (ini *INI) GetAll() SectionMap
- func (ini *INI) GetBool(key string) (value bool, ok bool)
- func (ini *INI) GetFloat(key string) (value float64, ok bool)
- func (ini *INI) GetInt(key string) (value int, ok bool)
- func (ini *INI) GetKvmap(section string) (kvmap Kvmap, ok bool)
- 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) Reset()
- func (ini *INI) SectionGet(section, key string) (value string, ok bool)
- func (ini *INI) SectionGetBool(section, key string) (value bool, ok bool)
- func (ini *INI) SectionGetFloat(section, key string) (value float64, ok bool)
- func (ini *INI) SectionGetInt(section, key string) (value int, ok 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) Write(w io.Writer) error
- type Kvmap
- type SectionMap
Constants ¶
const ( DefaultSection = "" DefaultLineSeperator = "\n" DefaultKeyValueSeperator = "=" )
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 will inherit 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) Merge ¶
Merge merges the data in another INI (from) to this INI (ini), and from INI will not be changed
func (*INI) Parse ¶
Parse parse 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) 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 get a value as bool. See GetBool for more detail
func (*INI) SectionGetFloat ¶
SectionGetFloat get value as float64
func (*INI) SectionGetInt ¶
SectionGetInt get value as int
func (*INI) SectionSet ¶
SectionSet store the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) SectionSetBool ¶
SectionSetBool store the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) SectionSetFloat ¶
SectionSetFloat store the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) SectionSetInt ¶
SectionSetInt store the section/key/value triple to this INI, creating it if it wasn't already present.
func (*INI) Set ¶
Set store the key/value pair to the default section of this INI, creating it if it wasn't already present.
func (*INI) SetBool ¶
SetBool store the key/value pair to the default section of this INI, creating it if it wasn't already present.
func (*INI) SetFloat ¶
SetFloat store 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 set INI.parseSection whether process the INI section when parsing
func (*INI) SetSkipCommits ¶
SetSkipCommits set INI.skipCommits whether skip commits when parsing