Documentation ¶
Overview ¶
package pref provides types used when passing preferences to plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithPreferences ¶
func WithPreferences(ctx context.Context, p Preferences) context.Context
WithPreferences returns a context.Context with p attacked.
Types ¶
type Preferences ¶
type Preferences interface { // Lookup looks up key in file, returning the unmarshalled value from the // file. Lookup(file, key string) (any, error) // SetDefault sets the default value for the given key in file. SetDefault(file, key string, dflt any) error }
Preferences is a type passed to plugins that may be used to load and save user preferences. When referencing a file, it should just be a relative path without an extension. vidar will check its settings directories and known config formats in order to read and unmarshal the file.
func FromCtx ¶
func FromCtx(ctx context.Context) Preferences
FromCtx returns the Preferences attached to ctx. It will panic if there is no value attached as the preferences for ctx.
The first thing vidar does when starting is attach preferences to the root context.Context, so a preferences value should always be available.