Documentation
¶
Overview ¶
Implement a universal parser for /etc/sysconfig files.
Index ¶
- type Sysconfig
- func (conf *Sysconfig) GetBool(key string, defaultValue bool) bool
- func (conf *Sysconfig) GetInt(key string, defaultValue int) int
- func (conf *Sysconfig) GetIntArray(key string, defaultValue []int) (ret []int)
- func (conf *Sysconfig) GetString(key, defaultValue string) string
- func (conf *Sysconfig) GetStringArray(key string, defaultValue []string) (ret []string)
- func (conf *Sysconfig) GetUint64(key string, defaultValue uint64) uint64
- func (conf *Sysconfig) Set(key string, value interface{})
- func (conf *Sysconfig) SetIntArray(key string, values []int)
- func (conf *Sysconfig) SetStringArray(key string, values []string)
- func (conf *Sysconfig) ToText() string
- type SysconfigEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sysconfig ¶
type Sysconfig struct { AllValues []*SysconfigEntry // All key-value pairs in the orignal order. KeyValue map[string]*SysconfigEntry }
Key-value pairs of a sysconfig file. It is able to convert back to original text in the original key order.
func ParseSysconfig ¶
Read sysconfig text and parse the text into memory structures.
func ParseSysconfigFile ¶
Read sysconfig file and parse the file content into memory structures.
func (*Sysconfig) GetBool ¶
Return bool value that belongs to the key, or the default value if key does not exist. True values are "yes" or "true".
func (*Sysconfig) GetInt ¶
Return integer value that belongs to the key, or the default value if the key does not exist or value is not an integer.
func (*Sysconfig) GetIntArray ¶
Assume the key carries a space-separated array of integers, return the array. Discard malformed integers.
func (*Sysconfig) GetString ¶
Return string value that belongs to the key, or the default value if the key does not exist.
func (*Sysconfig) GetStringArray ¶
Assume the key carries a space-separated array value, return the value array.
func (*Sysconfig) GetUint64 ¶
Return uint64 value that belongs to the key, or the default value if the key does not exist or value is not an integer.
func (*Sysconfig) SetIntArray ¶
Give a space-separated integer array value to a key. If the key does not yet exist, it is created.
func (*Sysconfig) SetStringArray ¶
Give a space-separated string array value to a key. If the key does not yet exist, it is created.
type SysconfigEntry ¶
type SysconfigEntry struct { LeadingComments []string // The comment lines leading to the key-value pair, including prefix '#', excluding end-of-line. Key string // The key. Value string // The value, excluding '=' character and double-quotes. Values will always come in double-quotes when converted to text. }
A single key-value pair in sysconfig file.