walker

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

pkg/walker/walker.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Violation

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

Violation represents a single import rule violation.

func (Violation) Column

func (v Violation) Column() int

func (Violation) File

func (v Violation) File() string

func (Violation) ImportPath

func (v Violation) ImportPath() string

func (Violation) Line

func (v Violation) Line() int

func (Violation) RuleDescription

func (v Violation) RuleDescription() string

func (Violation) RuleName

func (v Violation) RuleName() string

func (Violation) SourcePkg

func (v Violation) SourcePkg() string

type ViolationsError

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

ViolationsError is a collection of violations. Note: This is not an "error" in the Go sense unless the caller decides to wrap/return it as one. The CLI can print details and then return a sentinel error.

func (ViolationsError) Len

func (ve ViolationsError) Len() int

func (ViolationsError) Violations

func (ve ViolationsError) Violations() iter.Seq[Violation]

Violations returns an iterator over violations so callers can `range` over it.

type Walker

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

func NewWalker

func NewWalker(ctx context.Context, startPath string) (w *Walker, err error)

NewWalker creates a Walker by locating go.mod from startPath and reading its module path. startPath can be ".", "./foobar", or any path inside the target module.

func (*Walker) Walk

func (w *Walker) Walk(ctx context.Context, roots ...string) (ve ViolationsError, err error)

Walk walks through Go files under the given roots, checks import rules, and returns a ViolationsError if any rule is violated.

- roots are filesystem paths (e.g. ".", "./foobar", "internal"). - Import path normalization is computed relative to the module root directory. - If ctx is nil, the Walker's context (set in NewWalker) is used.

Jump to

Keyboard shortcuts

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