Documentation
¶
Overview ¶
This package is for dealing with Keyfiles. They are .ini-like configuration files used in multiple places in the XDG Specification e.g. Desktop Entries or Icon Themes). See https://specifications.freedesktop.org/desktop-entry-spec/latest/basic-format.html for the specification. You can also take a look at https://docs.gtk.org/glib/struct.KeyFile.html which also contains details about the file format.
Index ¶
- func IsSectionKeyNotExistsError(err error) bool
- func IsSectionNotExistsError(err error) bool
- type Keyfile
- type LocaleList
- type LocaleString
- type Section
- func (section *Section) GetBoolean(key string) (bool, error)
- func (section *Section) GetBooleanList(key string) ([]bool, error)
- func (section *Section) GetKeys() []string
- func (section *Section) GetLocaleList(key string) (*LocaleList, error)
- func (section *Section) GetLocaleString(key string) (*LocaleString, error)
- func (section *Section) GetNumber(key string) (float64, error)
- func (section *Section) GetNumberList(key string) ([]float64, error)
- func (section *Section) GetString(key string) (string, error)
- func (section *Section) GetStringList(key string) ([]string, error)
- func (section *Section) HasKey(key string) bool
- func (section *Section) SetBoolean(key string, boolean bool)
- func (section *Section) SetBooleanList(key string, boolList []bool)
- func (section *Section) SetLocaleString(key string, localeString *LocaleString)
- func (section *Section) SetNumber(key string, number float64)
- func (section *Section) SetNumberList(key string, numberList []float64)
- func (section *Section) SetString(key, str string)
- func (section *Section) SetStringList(key string, stringList []string)
- func (section *Section) String() string
- type SectionKeyNotExistsError
- type SectionNotExistsError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSectionNotExistsError ¶
Types ¶
type Keyfile ¶
type Keyfile struct {
ListSeparator string
// contains filtered or unexported fields
}
This type represents a Keyfile. Use the NewKeyfile function to create a new Keyfile.
func (*Keyfile) AddSection ¶
Adds a new Section
func (*Keyfile) GetSection ¶
Returns the section with the given name
func (*Keyfile) HasSection ¶
Check if a section exists
func (*Keyfile) SectionNames ¶
Returns the names of all section
type LocaleList ¶
type LocaleList struct {
ListSeparator string
// contains filtered or unexported fields
}
This type represents a localized list
func (*LocaleList) GetDefaultList ¶
func (localeList *LocaleList) GetDefaultList() []string
This returns the untranslated list
func (*LocaleList) GetLanguages ¶
func (localeList *LocaleList) GetLanguages() []string
This returns a list of all available languages
func (*LocaleList) GetTranslation ¶
func (localeList *LocaleList) GetTranslation(language string) []string
This returns the list for the given translation. If the languages does not exists, it will return the untranslated text.
func (*LocaleList) SetTranslation ¶
func (localeList *LocaleList) SetTranslation(language string, list []string)
This sets a translation
type LocaleString ¶
type LocaleString struct {
// contains filtered or unexported fields
}
This type represents a localized string
func (*LocaleString) GetDefaultText ¶
func (localeString *LocaleString) GetDefaultText() string
This returns the untranslated text
func (*LocaleString) GetLanguages ¶
func (localeString *LocaleString) GetLanguages() []string
This returns a list of all available languages
func (*LocaleString) GetTranslation ¶
func (localeString *LocaleString) GetTranslation(language string) string
This returns the text for the given translation. If the languages does not exists, it will return the untranslated text.
func (*LocaleString) SetTranslation ¶
func (localeString *LocaleString) SetTranslation(language, text string)
This sets a translation
type Section ¶
type Section struct {
Name string
// contains filtered or unexported fields
}
func (*Section) GetBoolean ¶
Returns the Boolean from the Key
func (*Section) GetBooleanList ¶
Returns the BooleanList from the Key
func (*Section) GetLocaleList ¶
func (section *Section) GetLocaleList(key string) (*LocaleList, error)
Returns the LocaleList from the Key
func (*Section) GetLocaleString ¶
func (section *Section) GetLocaleString(key string) (*LocaleString, error)
Returns the LocaleString from the Key
func (*Section) GetNumberList ¶
Returns the NumberList from the Key
func (*Section) GetStringList ¶
Returns the StringList from the Key
func (*Section) SetBoolean ¶
Sets the Boolean
func (*Section) SetBooleanList ¶
Sets the BooleanList
func (*Section) SetLocaleString ¶
func (section *Section) SetLocaleString(key string, localeString *LocaleString)
Sets the LocaleString
func (*Section) SetNumberList ¶
Sets the NumberList
func (*Section) SetStringList ¶
Sets the StringList
type SectionKeyNotExistsError ¶
type SectionKeyNotExistsError struct {
Key string
}
func (SectionKeyNotExistsError) Error ¶
func (err SectionKeyNotExistsError) Error() string
type SectionNotExistsError ¶
type SectionNotExistsError struct {
Name string
}
func (SectionNotExistsError) Error ¶
func (err SectionNotExistsError) Error() string