Help us shape the future of Go! Take the 2026 Go Developer Survey

filesystem

package
v0.4.45 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package filesystem is the swappable file-store contract used by file tools and runtime plugins (memory, schedule, skills, credentials, …).

Paths are slash-separated and interpreted by the backend (workspace-relative for local disk, object keys for S3, remote paths for SSH/FUSE, etc.). Empty path or "." is the backend root. Implementations should honor the workspace scope prefixes "global:" / "local:" (see cap/workspace.ParseScoped) so one instance can serve both tenant-local and shared-global files.

Not-found errors must match errors.Is(err, os.ErrNotExist). Writes create parent prefixes as needed and must be atomic (temp file + rename on local disk; a single PUT on object stores). Implementations may ignore .gitignore (local disk respects it; object stores typically do not).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	Name    string
	Path    string
	IsDir   bool
	ModTime time.Time
}

type FindRequest

type FindRequest struct {
	Pattern    string
	Path       string
	MaxResults int
}

type FindResult

type FindResult struct {
	Paths     []string
	Truncated bool
	Text      string
	Hint      string
}

type GrepMatch

type GrepMatch struct {
	Path    string
	Line    int
	Content string
}

type GrepRequest

type GrepRequest struct {
	Pattern    string
	Path       string
	Glob       string
	IgnoreCase bool
	Literal    bool
	Context    int
	MaxMatches int
}

type GrepResult

type GrepResult struct {
	Matches   []GrepMatch
	Truncated bool
	Text      string
	Hint      string
}

type Info added in v0.3.33

type Info struct {
	Name    string
	Path    string
	Size    int64
	IsDir   bool
	ModTime time.Time
}

Info is Stat metadata for a file or directory-like prefix.

type ReadFS added in v0.3.33

type ReadFS interface {
	Read(ctx context.Context, path string) ([]byte, error)
	Stat(ctx context.Context, path string) (Info, error)
	List(ctx context.Context, path string) ([]DirEntry, error)
}

ReadFS is the read/list surface. Remote and object-store backends implement directories as prefixes.

type SearchFS added in v0.3.33

type SearchFS interface {
	Grep(ctx context.Context, req GrepRequest) (GrepResult, error)
	Find(ctx context.Context, req FindRequest) (FindResult, error)
}

SearchFS is content and name search. Local disk walks the tree; S3 may list by prefix; a remote host may shell out to rg/find.

type Service

type Service interface {
	ReadFS
	WriteFS
	SearchFS
}

Service is the file store injected into tool/fs-workspace and runtime plugins. Standard kind: filesystem/local. Alternate backends (memory, S3, remote) register as filesystem/<name> and are wired through deps.fs.

type WriteFS added in v0.3.33

type WriteFS interface {
	Write(ctx context.Context, path string, data []byte, opts ...WriteOption) error
	// Append adds data to the end of path, creating it when missing. Object
	// stores may implement it as read-modify-write.
	Append(ctx context.Context, path string, data []byte) error
}

WriteFS creates or replaces a file. Parent prefixes are created as needed (no-op on stores without directories).

type WriteOption added in v0.3.33

type WriteOption func(*WriteOptions)

WriteOption customizes a single Write call.

func WithPerm added in v0.3.33

func WithPerm(perm os.FileMode) WriteOption

WithPerm sets the file permission (e.g. 0o600 for secrets files).

type WriteOptions added in v0.3.33

type WriteOptions struct {
	// Perm is the permission for newly created files. Zero keeps an existing
	// file's mode, or 0o644 for new files. Object stores ignore it.
	Perm os.FileMode
}

WriteOptions customizes a single Write call.

Jump to

Keyboard shortcuts

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