pinfs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package pinfs is the writable-filesystem abstraction for pin's outputs: vendored asset files and the pin.lock. OS is the default; alternative Writers pipe outputs into memory, an archive, or any other target without changing pin's resolve and sync logic.

Writer paths are slash-separated. The OS implementation joins them with its constructor-provided root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is an in-memory Writer. The contents map is the source of truth; iterate via Files() or look up a single entry via Get(). A zero-value *Memory is not usable — construct one via NewMemory.

func NewMemory

func NewMemory() *Memory

NewMemory returns an empty in-memory Writer.

func (*Memory) Files

func (m *Memory) Files() map[string][]byte

Files returns a snapshot of the in-memory contents keyed by slash-separated path. The returned map is owned by the caller; the returned byte slices are copies.

func (*Memory) Get

func (m *Memory) Get(path string) ([]byte, bool)

Get returns the bytes stored at path and whether the path exists. The returned slice is a copy.

func (*Memory) ReadFile

func (m *Memory) ReadFile(path string) ([]byte, error)

func (*Memory) Remove

func (m *Memory) Remove(path string) error

func (*Memory) WriteFile

func (m *Memory) WriteFile(path string, data []byte) error

type Writer

type Writer interface {
	WriteFile(path string, data []byte) error

	// ReadFile returns fs.ErrNotExist-wrapped for missing paths. Pin
	// uses it to skip rewriting an unchanged lockfile; an
	// implementation that doesn't support reads can return
	// fs.ErrNotExist unconditionally.
	ReadFile(path string) ([]byte, error)

	Remove(path string) error
}

Writer is the minimal interface pin uses to emit its outputs. Implementations must make WriteFile atomic, create parent directories on write, and tolerate not-exist errors on Remove.

func OS

func OS(root string) Writer

OS returns a Writer rooted at root. WriteFile uses tmp+rename; Remove prunes empty parent directories upward until reaching root.

Jump to

Keyboard shortcuts

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