Documentation
¶
Overview ¶
Package module provides Go module discovery and dependency operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseGoMod ¶
ParseGoMod reads and parses a go.mod file. Returns the module path and direct dependencies.
func UpdateGoMod ¶
UpdateGoMod updates internal dependency versions in a go.mod file.
Parameters:
- path: Path to go.mod file
- root: Root module path (to identify internal deps)
- versions: Map of module short name -> new version
Types ¶
type Graph ¶
type Graph struct {
Root *Module
Modules map[string]*Module // Short name -> Module (empty string key for root)
}
Graph represents the module dependency graph.
func Discover ¶
Discover finds all Go modules in a directory tree. Returns a Graph containing the root module and all submodules.
func (*Graph) AllModules ¶
AllModules returns all modules as a slice, sorted by short name.
func (*Graph) Dependents ¶
Dependents returns modules that depend on the given module.
func (*Graph) FindModule ¶
FindModule returns a module by short name. Use empty string to get the root module.
func (*Graph) IsInternal ¶
IsInternal returns true if the module path is internal to this repo.
func (*Graph) TopologicalSort ¶
TopologicalSort returns modules in dependency order (leaves first). Modules with no dependencies come first, then modules that only depend on those, and so on. This ensures that when processing modules in order, all dependencies are processed before dependents.
type Module ¶
type Module struct {
Name string // Full module path (e.g., "github.com/gojekfarm/xtools/xkafka")
ShortName string // Relative to root (e.g., "xkafka"), empty for root module
Path string // Filesystem path to module directory
Dependencies []string // Internal module dependencies (short names)
}
Module represents a Go module in the repository.