path

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(add string, sys bool) error

Add adds a path to the PATH environment variable. If sys is true, modifies system PATH; otherwise modifies user PATH. Note: setx has a 1024 character limit, so PowerShell is used instead.

func ApplyClean

func ApplyClean(newPath string, sys bool) error

ApplyClean applies the cleaned PATH to the registry.

func QuerySystemPath

func QuerySystemPath() ([]string, error)

QuerySystemPath queries the system PATH environment variable from registry.

func QueryUserPath

func QueryUserPath() ([]string, error)

QueryUserPath queries the user's PATH environment variable from registry.

func Remove

func Remove(remove string, sys bool) error

Remove removes a path from the PATH environment variable.

func RemoveInvalidPaths

func RemoveInvalidPaths(paths []InvalidPath, sys bool) error

RemoveInvalidPaths removes specified invalid paths from PATH.

func SearchSystemPath

func SearchSystemPath(keyword string) ([]string, error)

SearchSystemPath searches system PATH for entries containing keyword (case-insensitive).

func SearchUserPath

func SearchUserPath(keyword string) ([]string, error)

SearchUserPath searches user PATH for entries containing keyword (case-insensitive).

Types

type CleanResult

type CleanResult struct {
	Duplicates []string
	Invalid    []string
	NewPath    string
}

CleanResult contains the preview of paths to be cleaned.

func PreviewClean

func PreviewClean(sys bool) (CleanResult, error)

PreviewClean analyzes PATH and returns what would be cleaned.

type InvalidPath

type InvalidPath struct {
	Index int
	Path  string
}

InvalidPath represents an invalid path entry with its index.

func Check

func Check(sys bool) ([]InvalidPath, error)

Check finds invalid paths in PATH that don't exist on filesystem.

Jump to

Keyboard shortcuts

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