project

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 9 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 project resolves the project a working directory belongs to.

Precedence while walking upward from cwd (first match wins):

  1. <dir>/.acd-ctx directory (local mode, ID read from .acd-ctx/project-id)
  2. <dir>/.git (directory or file, covers worktrees and submodules)
  3. <dir>/<marker> for any configured marker (go.mod, package.json, ...)
  4. cwd itself when nothing matches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// ReadOnly forbids writes. A local project without .acd-ctx/project-id is
	// not given one; it gets the ID derived from its root path instead.
	ReadOnly bool
	// IDByRoot, when set, is asked for the ID already registered for a global
	// project root before the path hash is used. It keeps the identity of a
	// project that was moved (`project move` re-points root_path but keeps the
	// ID). It lives here as a hook so this package does not import the store.
	// Returning ok=false falls back to the hash of the root.
	IDByRoot func(root string) (id string, ok bool)
}

Options tunes ResolveWith.

type Resolved

type Resolved struct {
	ID      string
	Root    string
	Storage string // "global" | "local"
	Source  string // "local-dir" | "git" | "marker" | "cwd"
}

Resolved describes the project found for a working directory.

func Resolve

func Resolve(cwd string, markers []string) (Resolved, error)

Resolve finds the project root for cwd. markers are file names (e.g. "go.mod") whose presence marks a project root when no .acd-ctx or .git exists at the same or a closer level.

func ResolveWith

func ResolveWith(cwd string, markers []string, opts Options) (Resolved, error)

ResolveWith is Resolve with options. With ReadOnly set it never writes to the file system.

Jump to

Keyboard shortcuts

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