projectdetection

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoProjectDetected = errors.New("no project detected")

ErrNoProjectDetected is returned when no registered detector finds a project.

Functions

This section is empty.

Types

type Detector

type Detector interface {
	Detect(path string) (*ProjectInfo, error)
}

Detector detects project info from a directory (e.g. by parsing manifest files). Success: return (info, nil) with non-empty info.Name. Not applicable / no manifest: return (nil, nil). Error: return (nil, err); registry skips and tries next (best-effort).

type ProjectInfo

type ProjectInfo struct {
	Name string
}

ProjectInfo holds detected project metadata (extensible).

func DetectProject

func DetectProject(path string) (*ProjectInfo, error)

DetectProject detects project name from the given directory path using all registered detectors. Returns the first successful result, or (nil, ErrNoProjectDetected) when no detector finds a project.

type Registry

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

Registry holds an ordered list of detectors; first success wins.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty registry.

func (*Registry) Detect

func (r *Registry) Detect(path string) (*ProjectInfo, error)

Detect runs all detectors in order; returns first non-nil ProjectInfo with non-empty Name, or (nil, ErrNoProjectDetected) if none succeed.

func (*Registry) Register

func (r *Registry) Register(d Detector)

Register appends a detector to the registry (order matters).

Jump to

Keyboard shortcuts

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