Documentation ¶
Index ¶
- Constants
- Variables
- func GetINIFileDescriptiveName(fileName string) string
- func GetINIFileVersionSectionEntry(fileName, entryName string) string
- type INIEntry
- type INIFile
- type Operator
- 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) SetStrArray(key string, values []string)
- func (conf *Sysconfig) ToText() string
- type SysconfigEntry
Constants ¶
const ( OperatorLessThan = "<" OperatorLessThanEqual = "<=" OperatorMoreThan = ">" OperatorMoreThanEqual = ">=" OperatorEqual = "=" )
Operator definitions
Variables ¶
var RegexKeyOperatorValue = regexp.MustCompile(`([\w.+_-]+)\s*([<=>]+)\s*["']*(.*?)["']*$`)
RegexKeyOperatorValue breaks up a line into key, operator, value.
Functions ¶
func GetINIFileDescriptiveName ¶
GetINIFileDescriptiveName return the descriptive name of the Note
func GetINIFileVersionSectionEntry ¶
GetINIFileVersionSectionEntry returns the field 'entryName' from the version section of the Note configuration file
Types ¶
type INIFile ¶
INIFile contains all key-value pairs of an INI file.
type Operator ¶
type Operator string
Operator is the comparison or assignment operator used in an INI file entry
type Sysconfig ¶
type Sysconfig struct { AllValues []*SysconfigEntry // All key-value pairs in the orignal order. KeyValue map[string]*SysconfigEntry }
Sysconfig contains key-value pairs of a sysconfig file. It is able to convert back to original text in the original key order.
func ParseSysconfig ¶
ParseSysconfig read sysconfig text and parse the text into memory structures.
func ParseSysconfigFile ¶
ParseSysconfigFile read sysconfig file and parse the file content into memory structures.
func (*Sysconfig) GetBool ¶
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 ¶
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 ¶
GetIntArray assume the key carries a space-separated array of integers, return the array. Discard malformed integers.
func (*Sysconfig) GetString ¶
GetString return string value that belongs to the key, or the default value if the key does not exist.
func (*Sysconfig) GetStringArray ¶
GetStringArray assume the key carries a space-separated array value, return the value array.
func (*Sysconfig) GetUint64 ¶
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 ¶
SetIntArray give a space-separated integer array value to a key. If the key does not yet exist, it is created.
func (*Sysconfig) SetStrArray ¶
SetStrArray 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. }
SysconfigEntry contains a single key-value pair in sysconfig file.