unit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package unit names units and folders by their path from the repo's root, the one name every clone and worktree of a repo shares.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPath = errors.New("not a path from the repo's root")

ErrInvalidPath is returned, wrapped, for a path that isn't one from the root: empty, absolute, or climbing out of it.

Functions

This section is empty.

Types

type Naming

type Naming struct {
	// From is the folder the names are read from: the run's target, or
	// the folder its units share where one is outside the target.
	From Path
	// AboveRoot reports whether the names are read from the folder above
	// the root, From, as where the root is a unit beside others: each name
	// then begins with the repo's name.
	AboveRoot bool
	// Header are the folders every unit sits in at the same depth below
	// From, taken out of each name and named once, in depth order.
	Header []string
	// Names are the units' names, in the order the units came.
	Names []string
}

Naming is how a run names its units in views (spec 2.7.1, 2.7.3).

func Names

func Names(rootName string, target Path, units []Path) Naming

Names names units, each at or below target unless a dependency brings it in from outside, in a repo called rootName, its identity's name, which every clone and worktree shares, never the folder a checkout sits in: a unit's name is its path from the run's target, less any folder every unit shares at the same depth, which the header names once. A unit outside the target names every unit from the folder they share instead. A name keeps at least its unit's own folder: a unit that is the folder names are read from is named by its own folder's name, the root's by rootName, and beside units inside it, names are read from the folder above, so no two names are one.

type Path

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

Path is a slash path from the repo's root, clean and inside it: "." for the root itself. The zero Path is no path at all.

func ParsePath

func ParsePath(s string) (Path, error)

ParsePath reads a slash path from the root, cleaning it, so "./a/b/" and "a/x/../b" are both "a/b". It refuses an empty or absolute path, and one that climbs above the root.

func Root

func Root() Path

Root is the path of the root itself.

func Shared

func Shared(paths []Path) Path

Shared is the deepest folder at or above every path: the folder the paths share. Of no paths it's the root.

func (Path) Base

func (p Path) Base() string

Base is p's last folder name, "." for the root.

func (Path) IsRoot

func (p Path) IsRoot() bool

IsRoot reports whether p is the root itself.

func (Path) IsZero

func (p Path) IsZero() bool

IsZero reports whether p was never set.

func (Path) Join

func (p Path) Join(name string) (Path, error)

Join is the path of name inside p.

func (Path) Names

func (p Path) Names() []string

Names are p's folder names from the root down, none for the root.

func (Path) Parent

func (p Path) Parent() (Path, bool)

Parent is the folder holding p, and false for the root, which has none.

func (Path) String

func (p Path) String() string

String is the path as a slash path, "." for the root.

func (Path) Under

func (p Path) Under(base Path) bool

Under reports whether p is base or a folder below it.

type Row

type Row struct {
	// Chain are the folder names the row shows: one, or a chain of
	// folders each holding one folder and no unit, shown as one row.
	Chain []string
	// Path is the folder the row opens: the chain's last.
	Path Path
	// Unit reports whether Path is a unit.
	Unit bool
}

Row is one row of a folder's listing in the columns (spec 2.7.2).

func Rows

func Rows(units []Path, folder Path) []Row

Rows lists folder's children among units' paths, a row each, by name: a unit, or a folder of units, joined into one row with the folders it leads through while each holds one folder and no unit.

Jump to

Keyboard shortcuts

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