storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package storage provides JSON file-based persistence for SNIP entities.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("entity not found")
	ErrDuplicateName = errors.New("entity with this name already exists")
)

Common storage errors.

Functions

This section is empty.

Types

type Repositories

type Repositories struct {
	Snippets   domain.SnippetRepository
	Categories domain.CategoryRepository
	Tags       domain.TagRepository
	// contains filtered or unexported fields
}

Repositories bundles all repository implementations with shared state. All repositories share the same underlying store for data consistency.

func New

func New(filepath string) *Repositories

New creates repositories with all implementations sharing the same store.

func (*Repositories) Load

func (r *Repositories) Load() error

Load reads all data from the JSON file into memory. If the file doesn't exist, this is not an error.

func (*Repositories) Save

func (r *Repositories) Save() error

Save persists all data to the JSON file atomically.

Jump to

Keyboard shortcuts

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