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

workspace

package
v0.1.0-alpha.3 Latest Latest
Warning

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

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

Documentation

Overview

Package workspace manages the user's workspace: workspace.yaml, the collections mounted into it, and its private data directory. A workspace is never stored in a collection repository.

Index

Constants

View Source
const DefaultName = "default"

DefaultName is the workspace used when none is named.

View Source
const DefaultUser = "default"

DefaultUser is the user everything a person makes in the app belongs to. There is only one for now; the directory layout is ready for more.

Variables

View Source
var (
	ErrAlreadyMounted = errors.New("collection already mounted")
	ErrNotMounted     = errors.New("collection not mounted")
)

Mount errors.

Functions

func CheckMounts

func CheckMounts(ws model.Workspace, home string, exists func(string) bool) diag.List

CheckMounts reports every mount whose directory does not exist.

func DataDir

func DataDir(p settings.Paths, name string, collection model.ID) string

DataDir holds run history, saved responses and cookies for one collection in the named workspace.

func Dir

func Dir(p settings.Paths, name string) string

Dir is the directory of the named workspace.

func DirExists

func DirExists(path string) bool

DirExists reports whether path is an existing directory.

func DraftsDir

func DraftsDir(p settings.Paths, name string) string

DraftsDir holds the named workspace's drafts: collections the user has not saved to a folder of their own yet.

func EnvironmentsDir

func EnvironmentsDir(p settings.Paths, name string) string

EnvironmentsDir holds the workspace's environments. They belong to the workspace, not to a collection: every collection sees the same set, and the files are personal (never committed with a collection).

func ExpandPath

func ExpandPath(path, home string) string

ExpandPath replaces a leading "~" or "~/" with home. "~user" forms are left alone: Flow-I does not look up other users' home directories.

func KeptDir

func KeptDir(p settings.Paths, name string) string

KeptDir holds the unsaved edits of flows that were kept when the app quit, one file per flow, until the flow is opened again.

func LegacyDraftsDir

func LegacyDraftsDir(p settings.Paths, name string) string

LegacyDraftsDir is where drafts lived before they belonged to a user. Drafts already there stay there and are still drafts.

func LoadOrCreate

func LoadOrCreate(p settings.Paths, name string, c Codec, idSource *ids.Source) (model.Workspace, diag.List, error)

LoadOrCreate reads the named workspace, creating it with a fresh id on first use.

func Mount

func Mount(ws model.Workspace, id model.ID, path string, resolve PathResolver) (model.Workspace, error)

Mount returns a copy of ws with the collection added. The path is kept as given (so "~" survives), but duplicates are detected on the resolved path.

func Relocate

func Relocate(ws model.Workspace, id model.ID, path string) (model.Workspace, error)

Relocate returns a copy of ws with the collection's path changed.

func Save

func Save(p settings.Paths, c Codec, ws model.Workspace) error

Save writes workspace.yaml atomically. Its location comes from ws.File, or the default location for the workspace's directory when unset.

func TrashDir

func TrashDir(p settings.Paths, name string) string

TrashDir holds what was moved out of the drafts and not deleted yet.

func Unmount

func Unmount(ws model.Workspace, id model.ID) (model.Workspace, error)

Unmount returns a copy of ws without the collection.

func UserDir

func UserDir(p settings.Paths, name, user string) string

UserDir holds what belongs to one user of the named workspace.

Types

type Codec

type Codec interface {
	DecodeWorkspace(file string, data []byte) (model.Workspace, diag.List)
	EncodeWorkspace(model.Workspace) ([]byte, error)
}

Codec converts workspace.yaml to and from the model.

type PathResolver

type PathResolver func(path string) (string, error)

PathResolver turns a mount path into a comparable form (absolute, with symlinks resolved). Injected so tests need no real filesystem.

Jump to

Keyboard shortcuts

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