store

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package store is a simple persistent key/value store backed by a JSON file in the app data directory. It is pure Go and works identically on every target (desktop, mobile, server) — no native provider, no permission, no build tag. Values are stored as raw JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAppName added in v0.9.0

func SetAppName(name string)

SetAppName names the directory the default store lives in: <UserConfigDir>/<appName>/store.json. App.New calls this with Config.AppID (falling back to Title).

Without it every goleo app on a machine shared ONE store.json under "goleo-app" — two different apps read and clobbered each other's keys. Call it before the first Default(), which App.New does; afterwards the path is fixed for the process.

Types

type Store

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

Store is a concurrency-safe JSON-file-backed key/value store.

func Default

func Default() (*Store, error)

Default returns the process-wide store at <appDataDir>/<appName>/store.json.

func Open

func Open(path string) (*Store, error)

Open loads (or lazily creates) a store at the given file path.

func (*Store) Clear

func (s *Store) Clear() error

func (*Store) Delete

func (s *Store) Delete(key string) error

func (*Store) Get

func (s *Store) Get(key string) (json.RawMessage, bool)

func (*Store) Keys

func (s *Store) Keys() []string

func (*Store) Set

func (s *Store) Set(key string, value json.RawMessage) error

Jump to

Keyboard shortcuts

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