settings

package
v1.56.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package settings persists small cross-device user settings as a JSON map (key to value) in the state directory. The file is read and written through on every call, so several serve processes sharing the state dir see each other's changes and a fresh process picks up the latest values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is the file-backed settings map. Safe for concurrent use.

func New

func New(path string) *Store

New returns a store backed by path. The file is read on demand, not now.

func (*Store) Delete

func (s *Store) Delete(key string)

Delete takes the key out of the file, which is not the same as storing an empty value: a setting whose empty value is a real choice reads as set afterwards, and Lookup is what tells the two apart. Removing it is what puts a setting back to "never answered", so whatever the code calls its default applies again, including a default a later version changes.

func (*Store) Get

func (s *Store) Get(key string) string

Get returns the stored value for key, or "" when absent.

func (*Store) Lookup

func (s *Store) Lookup(key string) (string, bool)

Lookup returns the stored value for key and whether it is there at all. A setting whose empty value is a real choice, such as a list someone emptied on purpose, cannot tell that apart from never having been set with Get alone.

func (*Store) Set

func (s *Store) Set(key, value string)

Set stores the value for key, merging into whatever is already on disk.

Jump to

Keyboard shortcuts

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