Documentation ¶
Overview ¶
Package keyfile implements the ini file format that is used in many of the xdg specs.
WARNING: This package is meant for internal use and the API may change without warning.
Index ¶
- Variables
- type KeyFile
- func (kf *KeyFile) Bool(g, k string) (bool, error)
- func (kf *KeyFile) GroupExists(g string) bool
- func (kf *KeyFile) Groups() []string
- func (kf *KeyFile) KeyExists(g, k string) bool
- func (kf *KeyFile) Keys(g string) []string
- func (kf *KeyFile) LocaleString(g, k string) (string, error)
- func (kf *KeyFile) LocaleStringList(g, k string) ([]string, error)
- func (kf *KeyFile) LocaleStringListWithLocale(g, k string, l Locale) ([]string, error)
- func (kf *KeyFile) LocaleStringWithLocale(g, k string, l Locale) (string, error)
- func (kf *KeyFile) Number(g, k string) (float64, error)
- func (kf *KeyFile) String(g, k string) (string, error)
- func (kf *KeyFile) StringList(g, k string) ([]string, error)
- func (kf *KeyFile) Value(g, k string) string
- func (kf *KeyFile) ValueList(g, k string) ([]string, error)
- type Locale
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalid = errors.New("invalid keyfile format") ErrBadEscapeSequence = errors.New("bad escape sequence") ErrUnexpectedEndOfString = errors.New("unexpected end of string") )
These errors can be returned if there is a problem processing a keyfile's contents.
var ErrBadLocaleFormat = errors.New("bad locale format")
ErrBadLocaleFormat is returned by ParseLocale when the given string is not formatted properly (for example, missing the lang component).
Functions ¶
This section is empty.
Types ¶
type KeyFile ¶
type KeyFile struct {
// contains filtered or unexported fields
}
KeyFile is an implementation of the keyfile format used by several FreeDesktop.org (xdg) specs. The key values without a header section can be accessed using an empty string as the group.
func (*KeyFile) GroupExists ¶
GroupExists returns a bool indicating whether the given group 'g' exists.
func (*KeyFile) KeyExists ¶
KeyExists returns a bool indicating whether the given group 'g' and key 'k' exists.
func (*KeyFile) LocaleString ¶
LocaleString returns the value for group 'g' and key 'k' using the system's locale.
func (*KeyFile) LocaleStringList ¶
LocaleStringList returns a slice of strings for group 'g' and key 'k'.
func (*KeyFile) LocaleStringListWithLocale ¶
LocaleStringListWithLocale returns a slice of strings for group 'g', key 'k', and locale 'l'.
func (*KeyFile) LocaleStringWithLocale ¶
LocaleStringWithLocale returns the value for group 'g', key 'k', and locale 'l'.
func (*KeyFile) String ¶
String returns the value for group 'g' and key 'k' as a string. String will return a blank string if the key doesn't exist; use GroupExists or KeyExists to if you need to treat a missing value differently then a blank value.
func (*KeyFile) StringList ¶
StringList returns a slice of strings for group 'g' and key 'k'. StringList will return an empty slice if the key doesn't exist; use GroupExists or KeyExists to if you need to treat a missing value differently then a blank value.
func (*KeyFile) Value ¶
Value returns the raw string for group 'g' and key 'k'. Value will return a blank string if the key doesn't exist; use GroupExists or KeyExists to if you need to treat a missing value differently then a blank value.
type Locale ¶
type Locale struct {
// contains filtered or unexported fields
}
Locale represents a locale for use in parsing translatable strings.
func DefaultLocale ¶
func DefaultLocale() Locale
DefaultLocale returns the locale specified by the environment.
func ParseLocale ¶
ParseLocale parses a locale in the format
lang_COUNTRY.ENCODING@MODIFIER
where "_COUNTRY", ".ENCODING", and "@MODIFIER" can be omitted. A blank string, "C", and "POSIX" are special cases that evaluate to a blank Locale.