store

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package store resolves the nt data directory ($NT_DIR) and the paths of the files within it. The store is global by design (SPEC §2): one directory, always available regardless of the current working directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads a file, returning empty bytes (not an error) when it does not exist yet — tasks.txt may legitimately be absent on a fresh store.

func ResolveDir added in v0.4.0

func ResolveDir() (string, error)

ResolveDir returns the store directory ($NT_DIR, else $XDG_DATA_HOME/nt, else ~/.local/share/nt) WITHOUT creating it — for callers (config, web) that need the path before, or without, opening the store.

func WriteAtomic

func WriteAtomic(path string, data []byte, perm os.FileMode) error

WriteAtomic writes data to path atomically: it writes a temp file in the same directory (so rename stays on one filesystem) then renames over the target. On POSIX, rename(2) is atomic, so a reader never sees a half-written file (SPEC §6.1).

Types

type Store

type Store struct {
	Dir string
}

Store is a handle to a resolved nt data directory.

func Open

func Open() (*Store, error)

Open resolves the store directory and ensures it (and notes/) exist.

Resolution order:

  1. $NT_DIR if set
  2. $XDG_DATA_HOME/nt
  3. ~/.local/share/nt

func (*Store) DoneFile

func (s *Store) DoneFile() string

func (*Store) IsFresh

func (s *Store) IsFresh() bool

IsFresh reports whether the store has no tasks file and no notes yet — used to decide whether to run first-run onboarding (SPEC §10).

func (*Store) LockFile

func (s *Store) LockFile() string

func (*Store) LogFile

func (s *Store) LogFile() string

func (*Store) NotesDir

func (s *Store) NotesDir() string

func (*Store) TasksFile

func (s *Store) TasksFile() string

func (*Store) UndoFile

func (s *Store) UndoFile() string

Jump to

Keyboard shortcuts

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