keyfile

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSectionKeyNotExistsError

func IsSectionKeyNotExistsError(err error) bool

func IsSectionNotExistsError

func IsSectionNotExistsError(err error) bool

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 FromFile

func FromFile(path string) (*Keyfile, error)

Creates a Keyfile from a File

func FromString

func FromString(text string) (*Keyfile, error)

Creates a Keyfile from a String

func NewKeyfile

func NewKeyfile() *Keyfile

Creates a new Keyfile

func (*Keyfile) AddSection

func (keyfile *Keyfile) AddSection(name string) *Section

Adds a new Section

func (*Keyfile) GetSection

func (keyfile *Keyfile) GetSection(name string) (*Section, error)

Returns the section with the given name

func (*Keyfile) HasSection

func (keyfile *Keyfile) HasSection(name string) bool

Check if a section exists

func (*Keyfile) SectionNames

func (keyfile *Keyfile) SectionNames() []string

Returns the names of all section

func (*Keyfile) String

func (keyfile *Keyfile) String() string

type LocaleList

type LocaleList struct {
	ListSeparator string
	// contains filtered or unexported fields
}

This type represents a localized list

func NewLocaleList

func NewLocaleList() *LocaleList

This creates a new LocaleList

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 NewLocaleString

func NewLocaleString() *LocaleString

This creates a new LocaleString

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

func (section *Section) GetBoolean(key string) (bool, error)

Returns the Boolean from the Key

func (*Section) GetBooleanList

func (section *Section) GetBooleanList(key string) ([]bool, error)

Returns the BooleanList from the Key

func (*Section) GetKeys

func (section *Section) GetKeys() []string

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) GetNumber

func (section *Section) GetNumber(key string) (float64, error)

Returns the Number from the Key

func (*Section) GetNumberList

func (section *Section) GetNumberList(key string) ([]float64, error)

Returns the NumberList from the Key

func (*Section) GetString

func (section *Section) GetString(key string) (string, error)

Returns the String from the Key

func (*Section) GetStringList

func (section *Section) GetStringList(key string) ([]string, error)

Returns the StringList from the Key

func (*Section) HasKey

func (section *Section) HasKey(key string) bool

func (*Section) SetBoolean

func (section *Section) SetBoolean(key string, boolean bool)

Sets the Boolean

func (*Section) SetBooleanList

func (section *Section) SetBooleanList(key string, boolList []bool)

Sets the BooleanList

func (*Section) SetLocaleString

func (section *Section) SetLocaleString(key string, localeString *LocaleString)

Sets the LocaleString

func (*Section) SetNumber

func (section *Section) SetNumber(key string, number float64)

Sets the Number

func (*Section) SetNumberList

func (section *Section) SetNumberList(key string, numberList []float64)

Sets the NumberList

func (*Section) SetString

func (section *Section) SetString(key, str string)

Sets the String

func (*Section) SetStringList

func (section *Section) SetStringList(key string, stringList []string)

Sets the StringList

func (*Section) String

func (section *Section) String() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL