prefs

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Preferences

type Preferences interface {
	// ReadPropertyString attempts to read the property with the given key
	// from the prefs store and then attempts to type assert any non-nil value
	// as a string. If the store does not exist, or if the store cannot be parsed,
	// or the property does not exist, the empty string is returned.
	ReadPropertyString(key string) (string, error)

	// ReadPropertyInt attempts to read the property with the given key
	// from the prefs store and then attempts to type assert any non-nil value
	// as an int. If the store does not exist, or if the store cannot be parsed,
	// or the property does not exist, 0 is returned.
	ReadPropertyInt(key string) (int, error)

	// WriteProperty persists a key-value pair to the prefs store.
	// If the store cannot be loaded, the write will fail and an error
	// will be logged.
	WriteProperty(key string, value interface{}) error
}

type Prefs

type Prefs struct {
	// contains filtered or unexported fields
}

func Load

func Load(fileName string) Prefs

func (Prefs) ReadPropertyInt

func (p Prefs) ReadPropertyInt(key string) (int, error)

ReadPropertyInt attempts to read the property with the given key from the prefs store and then attempts to type assert any non-nil value as an int. If the store does not exist, or if the store cannot be parsed, or the property does not exist, 0 is returned.

func (Prefs) ReadPropertyString

func (p Prefs) ReadPropertyString(key string) (string, error)

ReadPropertyString attempts to read the property with the given key from the prefs store and then attempts to type assert any non-nil value as a string. If the store does not exist, or if the store cannot be parsed, or the property does not exist, the empty string is returned.

func (Prefs) WriteProperty

func (p Prefs) WriteProperty(key string, value interface{}) error

WriteProperty persists a key-value pair to the prefs store. If the store cannot be loaded, the write will fail and an error will be logged.

Jump to

Keyboard shortcuts

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