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

state

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package state handles reading and writing space metadata to XDG data files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir() string

DataDir returns the directory where space state files are stored: $XDG_DATA_HOME/wtg/spaces (default ~/.local/share/wtg/spaces).

func DataRoot added in v1.6.0

func DataRoot() string

DataRoot returns the wtg data directory, following the XDG Base Directory spec: $XDG_DATA_HOME/wtg (default ~/.local/share/wtg).

func Delete

func Delete(name string) error

Delete removes the state file for the named space. Returns a wrapped fs.ErrNotExist if no state file exists.

func Save

func Save(space *Space) error

Save writes the space state to disk, creating the state directory if needed.

Types

type RepoEntry

type RepoEntry struct {
	Name         string `yaml:"name"`              // short name relative to discovery.root_dir
	RepoPath     string `yaml:"repo_path"`         // absolute path to the main clone
	WorktreePath string `yaml:"worktree_path"`     // absolute path to the linked worktree or symlink
	Symlink      bool   `yaml:"symlink,omitempty"` // true if this entry is a symlink to the main clone
}

RepoEntry describes one repo's participation in a space.

type Space

type Space struct {
	Name        string      `yaml:"name"`
	Path        string      `yaml:"path"`   // absolute path to the workspace root
	Branch      string      `yaml:"branch"` // branch shared across all repos
	CreatedAt   time.Time   `yaml:"created_at"`
	Repos       []RepoEntry `yaml:"repos"`
	GoWorkspace bool        `yaml:"go_workspace"` // whether a go.work was written
}

Space holds the persisted metadata for a workspace.

func List

func List() ([]*Space, error)

List returns all spaces found in the state directory. A missing state directory is treated as empty (not an error).

func Load

func Load(name string) (*Space, error)

Load reads the state for the named space. Returns a wrapped fs.ErrNotExist if no state file exists for that name.

Jump to

Keyboard shortcuts

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