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

workspace

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package workspace holds fetched files in the lockfile account: one private directory per handle, a random file name, never the source name. Nothing here is shown to the agent but the handle; Info is for the audit.

Index

Constants

View Source
const (
	DefaultMaxBytes = 1 << 30
	DefaultTTL      = 30 * time.Minute
)

Defaults for zero Config fields.

Variables

View Source
var (
	ErrTooLarge      = errors.New("workspace: file too large")
	ErrExpired       = errors.New("handle_expired")
	ErrUnknownHandle = errors.New("workspace: unknown handle")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Dir      string
	MaxBytes int64 // all handles together
	TTL      time.Duration
	Now      func() time.Time
}

type Handle

type Handle string

Handle names a fetched file for the agent: "f_" and 10 base62 characters from crypto/rand, unrelated to anything about the file.

type Info

type Info struct {
	Size   int64
	SHA256 string
}

Info is audit-only data about a fetched file.

type Manager

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

func Open

func Open(c Config) (*Manager, error)

Open prepares the workspace root (0700) and removes everything a previous console left in it.

func (*Manager) Close

func (m *Manager) Close() error

Close deletes every handle's file.

func (*Manager) Create

func (m *Manager) Create(r io.Reader, max int64) (h Handle, info Info, err error)

Create streams r into a new handle, hashing as it copies. It fails with ErrTooLarge, and leaves nothing behind, as soon as the file exceeds max or the space left in the workspace.

func (*Manager) Expire

func (m *Manager) Expire()

Expire deletes the files of every handle past its TTL. The handles keep answering ErrExpired.

func (*Manager) OpenFile

func (m *Manager) OpenFile(h Handle) (*os.File, Info, error)

OpenFile opens a handle's file read-only, from its start.

func (*Manager) Release

func (m *Manager) Release(h Handle) error

Release deletes a handle's file now.

Jump to

Keyboard shortcuts

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