Documentation
¶
Overview ¶
Package wspath defines the typed coordination key for a workspace file. A Path is an absolute, syntactically clean filesystem path that the coordination layer uses as a hold key, hold-release key, and the value carried in coord.File. The substrate (holds) and the domain (coord, swarm, dispatch) agree on the same key by construction; no caller hand-rolls path normalization.
Paths are produced by exactly two constructors: New, which wraps an already-absolute path, and NewRelative, which joins a workspace- relative path onto an absolute workspace root and rejects any result that escapes the root via "..". Both return ErrInvalid on bad input rather than producing a Path that fails downstream.
The package re-exports as coord.Path via a type alias so the public vocabulary stays "coord.Path" while the implementation stays dependency-free. Holds depends on wspath directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("wspath: invalid path")
ErrInvalid wraps every constructor failure. Callers can errors.Is against it to distinguish bad input from substrate errors.
Functions ¶
This section is empty.
Types ¶
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is the typed coordination key for a workspace file. The zero value is invalid — use IsZero to test for it.
func Must ¶
Must wraps New and panics on error. Intended for tests and for programs whose input is a compile-time-known absolute path; every other caller should use New and handle ErrInvalid.
func New ¶
New wraps an absolute filesystem path in a Path. The input is passed through filepath.Clean, so "/a//b/", "/a/./b", and "/a/b" all produce the same canonical Path. Returns an ErrInvalid-wrapped error when input is empty or not absolute.
func NewRelative ¶
NewRelative joins workspaceDir and rel into a Path anchored inside workspaceDir. workspaceDir must itself be absolute. The cleaned join must lie at or under workspaceDir; a rel that escapes via ".." is rejected. rel must not be absolute (use New for that path).
func (Path) AsAbsolute ¶
AsAbsolute returns the canonical absolute path string.
func (Path) AsKey ¶
AsKey returns the coordination-key form of the path. Currently equal to AsAbsolute; kept distinct so a future schema change to the hold-bucket key format can stay invisible to callers.