storage

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package storage provides common storage utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(dataDir, name string, v json.Unmarshaler) error

Load reads a JSON snapshot from dataDir/{name}.json and unmarshals it into v. Returns nil if the file does not exist.

func Save

func Save(dataDir, name string, v json.Marshaler) error

Save marshals v to JSON and writes it atomically to dataDir/{name}.json.

func SaveBytes added in v0.22.0

func SaveBytes(dataDir, name string, data []byte) error

SaveBytes writes pre-marshaled JSON data atomically to dataDir/{name}.json. This is useful when the caller already holds a lock and cannot use MarshalJSON (which may also acquire a lock, causing a deadlock).

Types

This section is empty.

Jump to

Keyboard shortcuts

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