Help us shape the future of Go! Take the 2026 Go Developer Survey

asdf

package
v1.65.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultIgnoredDirs = []string{
	".git",
	".github",
	".vscode",
	".idea",
	"node_modules",
	"vendor",
	".venv",
	"venv",
	"target",
	"dist",
	"build",
	".cache",
	".asdf",
	".cargo",
}

DefaultIgnoredDirs is a list of directory names to skip during recursive scanning for .tool-versions.

Functions

func CalculateDirSize

func CalculateDirSize(dirPath string) int64

CalculateDirSize recursively calculates the size in bytes of a directory, ignoring symbolic links to prevent double counting.

func FindToolVersionFiles

func FindToolVersionFiles(rootDirs []string) ([]string, error)

FindToolVersionFiles recursively scans the given root directories for .tool-versions files, skipping common build, dependency, and VCS directories.

func FindToolVersionFilesWithProgress added in v1.40.0

func FindToolVersionFilesWithProgress(
	rootDirs []string,
	onProgress func(currentDir string, foundCount int),
) ([]string, error)

FindToolVersionFilesWithProgress recursively scans the given root directories for .tool-versions files, invoking onProgress (if non-nil) whenever a directory is inspected or a file is found.

func GetASDFDataDir

func GetASDFDataDir(homeDir string) string

GetASDFDataDir resolves the location of the asdf data directory.

func ParseASDFListOutput

func ParseASDFListOutput(output string) (map[string][]string, error)

ParseASDFListOutput parses the text output of `asdf list` into a map of plugin names to slices of installed versions.

func ParseAndMergeToolVersions

func ParseAndMergeToolVersions(filePaths []string) (ToolVersions, []FileProtectionSummary, error)

ParseAndMergeToolVersions parses a list of .tool-versions files and merges all protected versions into a single ToolVersions map. It also returns per-file protection summaries.

func WriteToolVersions

func WriteToolVersions(filePath string, tv ToolVersions) error

WriteToolVersions updates or rewrites a .tool-versions file with the specified ToolVersions map.

Types

type CleanupTarget

type CleanupTarget struct {
	Plugin    string
	Version   string
	SizeBytes int64
}

CleanupTarget represents an installed plugin version eligible for removal.

func FilterRemovableVersions

func FilterRemovableVersions(
	installed map[string][]string,
	protected ToolVersions,
	targetPlugin, asdfDataDir string,
) []CleanupTarget

FilterRemovableVersions compares installed versions against protected versions in .tool-versions and returns a list of CleanupTargets eligible for removal. If targetPlugin is non-empty, only versions for that specific plugin are returned. If asdfDataDir is non-empty, disk size for each removable target will be calculated.

func (CleanupTarget) FormatSize

func (c CleanupTarget) FormatSize() string

FormatSize returns a human-readable string representation of SizeBytes (e.g., "12.4 MB").

func (CleanupTarget) FormatTargetLabel

func (c CleanupTarget) FormatTargetLabel() string

FormatTargetLabel returns a user-friendly label for a CleanupTarget including disk size, e.g. "nodejs @ 20.19.5 (112.4 MB)".

type FileProtectionSummary

type FileProtectionSummary struct {
	FilePath  string
	Protected ToolVersions
}

FileProtectionSummary tracks versions protected by a specific .tool-versions file.

func (FileProtectionSummary) FormatFileSummary

func (s FileProtectionSummary) FormatFileSummary(homeDir string) string

FormatFileSummary returns a formatted label describing protected versions in a file.

type MissingRequirement

type MissingRequirement struct {
	Plugin     string
	Version    string
	SourceFile string
}

MissingRequirement represents a version required by a .tool-versions file that is not installed.

func CheckMissingRequirements

func CheckMissingRequirements(summaries []FileProtectionSummary, installed map[string][]string) []MissingRequirement

CheckMissingRequirements compares requirements across all discovered .tool-versions files against installed versions, returning any missing requirements.

func (MissingRequirement) FormatSource

func (m MissingRequirement) FormatSource(homeDir string) string

FormatSource returns a user-friendly display path for the source file.

type ToolVersions

type ToolVersions map[string][]string

ToolVersions maps plugin names to their protected version strings as defined in .tool-versions.

func ParseToolVersions

func ParseToolVersions(r io.Reader) (ToolVersions, error)

ParseToolVersions reads from an io.Reader (such as a .tool-versions file) and returns a ToolVersions map of plugin -> protected versions.

func ParseToolVersionsFile

func ParseToolVersionsFile(filePath string) (ToolVersions, error)

ParseToolVersionsFile reads a .tool-versions file from the given path and returns a ToolVersions map of plugin -> protected versions.

Jump to

Keyboard shortcuts

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