statefile

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package statefile reads and writes the small JSON state files in the dev-cockpit state directory. Reads go through the file on every call and writes are atomic via a temp file rename, so several processes sharing a state dir stay consistent and a fresh process picks up the latest values. A file that exists but does not parse is quarantined as <path>.broken and treated as absent, so a later save can never silently overwrite state that is still recoverable from the broken file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(path string, v any)

Load unmarshals path into v. A missing or empty file leaves v untouched, a corrupt file is quarantined and logged.

func NewID

func NewID() string

NewID returns a short random identifier for state entries.

func Save

func Save(path string, mode os.FileMode, v any)

Save writes v to path atomically with the given file mode.

Types

This section is empty.

Jump to

Keyboard shortcuts

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