writes

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package writes is the one way Jade changes a file in the workspace (release plan 0.0.7, "One write path"). A write is atomic — a reader or a crash never sees half a file — and a change to several files lands in all of them or in none.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Digest

func Digest(data []byte) string

Digest names a file's contents: 12 hex characters of its SHA-256. Reads return it, and edits accept it as a precondition that sees every change to the file, not only Jade's.

func File

func File(path string, data []byte) error

File writes data to path atomically: a temporary file beside it, then a rename. An existing file keeps its permissions, and a symlink is followed, so the link stays a link and its target changes.

func Files

func Files(changes []Change) error

Files writes every change or none. What each path held is read first; if any write fails, the files already written are put back — a created file removed — and the error says which write failed and whether the restore held. A rename across four files that lands in three compiles nowhere.

func Observe

func Observe(root string, fn func(path string))

Observe registers fn to be told the path of every write or removal under root before it happens. The workspace uses it to record what a file held before the first change since a checkpoint, which no caller could otherwise supply. Several may observe one root: two sessions on one workspace each keep their own checkpoints. A single observer per root let the second session silently replace the first's.

func Remove

func Remove(path string) error

Remove deletes path through the write path, so observers see it first.

Types

type Change

type Change struct {
	Path   string
	Data   []byte
	Remove bool
}

Change is one file's new contents, or its removal.

Jump to

Keyboard shortcuts

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