dagnabit

package
v0.0.0-...-ed7c31d Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopologicalSort

func TopologicalSort(edges []Edge) (map[string]int, error)

TopologicalSort performs Kahn's algorithm on the given edges and returns a map from node name to its height in the dependency DAG. Leaf nodes (no dependencies) have height 0. Returns an error if a cycle is detected.

Types

type DependencyReader

type DependencyReader interface {
	ReadDependencies() (map[string][]Edge, error)
}

DependencyReader produces directed edges from a codebase, grouped by tree prefix (e.g., "lib", "internal").

type Edge

type Edge struct {
	Source string
	Target string
}

Edge represents a directed dependency: Source depends on Target.

type GoListReader

type GoListReader struct {
	ModulePath      string
	Dir             string
	PackagePrefixes []string
}

GoListReader reads Go package dependencies by shelling out to `go list`. ModulePath is the Go module path (e.g., "code.linenisgreat.com/dodder/go"). Dir is the working directory to run `go list` from. PackagePrefixes are directory prefixes containing packages (e.g., ["lib", "internal"]). Node names in returned edges include the prefix (e.g., "lib/_/ohio_buffer").

func (GoListReader) ReadDependencies

func (goListReader GoListReader) ReadDependencies() (map[string][]Edge, error)

type JustMover

type JustMover struct {
	Dir string
}

JustMover moves packages by shelling out to `just codemod-go-move_package`. Dir is the working directory containing the justfile.

func (JustMover) MovePackage

func (m JustMover) MovePackage(src, dst string) error

type LevelMapper

type LevelMapper interface {
	LevelName(height int) (string, error)
}

LevelMapper assigns names to topological heights. Height 0 is the lowest level (no internal dependencies).

type NATOLevelMapper

type NATOLevelMapper struct{}

func MakeNATOLevelMapper

func MakeNATOLevelMapper() NATOLevelMapper

func (NATOLevelMapper) LevelName

func (m NATOLevelMapper) LevelName(height int) (string, error)

type PackageMover

type PackageMover interface {
	MovePackage(src, dst string) error
}

PackageMover executes the move of a package from one path to another.

type Repositioner

type Repositioner struct {
	Reader  DependencyReader
	Mapper  LevelMapper
	Mover   PackageMover
	DryRun  bool
	Verbose bool
}

Repositioner orchestrates dependency reading, topological sorting, level mapping, and package moving.

func (*Repositioner) Run

func (repositioner *Repositioner) Run() error

Source Files

  • go_list_reader.go
  • just_mover.go
  • main.go
  • nato_level_mapper.go
  • repositioner.go
  • topological_sort.go

Jump to

Keyboard shortcuts

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