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

workdirs

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package workdirs reads the directories workflow can be pointed at: what is in one, whether it is there, and how a typed path or a directory is written. It lists names and asks whether a name is a directory; it never reads a file.

Index

Constants

View Source
const ListLimit = 1000

ListLimit bounds how many directories a listing holds, so a directory of thousands answers with what fits on a screen and says there was more.

Variables

View Source
var (
	// ErrNotFound is a directory that is not there.
	ErrNotFound = errors.New("there is no such directory")
	// ErrNotADirectory is a path that names something other than a directory.
	ErrNotADirectory = errors.New("that is not a directory")
	// ErrNotAbsolute is a path not written from the root.
	ErrNotAbsolute = errors.New("the path is not absolute")
	// ErrUnreadable is a directory that is there but cannot be listed.
	ErrUnreadable = errors.New("the directory cannot be read")
)

Functions

func Check

func Check(dir string) error

Check reports dir an absolute path to a directory that is there.

func Resolve

func Resolve(typed, base, home string) string

Resolve is the directory typed names: from the root as written, from your home after a ~, and from base otherwise; blank, it is base. A ~ is followed by either separator, so ~/src reads the same on Windows.

func Same

func Same(one, other string) bool

Same reports one and other the same directory however each is written, a link and where it leads included; a path that is not there is never the same as anything.

func Shown

func Shown(dir, home string) string

Shown is dir written from your home, ~/src/api, when it is under it, and as it is otherwise. The part under your home is written with forward slashes, as ~ itself is a Unix spelling.

Types

type Entry

type Entry struct {
	Name       string
	Repository bool
}

Entry is a directory in another: its name, and whether it is a repository's root.

type Listing

type Listing struct {
	Entries   []Entry
	Truncated bool
}

Listing is the directories in one, by name, and whether there were more than ListLimit.

func List

func List(dir, prefix string) (Listing, error)

List is the directories in dir whose names start with prefix in any case — all of them for "" — a directory linked to among them, sorted by name whatever its case, the first ListLimit kept. A hidden one is left out unless prefix starts with a dot: it is reached by typing its name.

type Match added in v0.11.0

type Match struct {
	Entry Entry
	// Letters is the place of each matched letter among the name's letters,
	// counted from zero.
	Letters []int
	Prefix  bool
}

Match is an entry whose name holds what was typed, letter by letter in order: where in the name each letter matched, and whether the name starts with them.

func Matching added in v0.11.0

func Matching(entries []Entry, typed string) []Match

Matching is the entries whose names hold typed's letters in order, whatever their case: those starting with typed first, then the rest, each kept in the order given. Every entry matches "".

Jump to

Keyboard shortcuts

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