asdf/internal/paths/paths.go
Trevor Brown 9f09f78ec0 feat(golang-rewrite): create shims.FindExecutable function for shim execution
* Create primitive `toolversions.Intersect` function
* Create `paths.RemoveFromPath` function
* Create `shims.FindExecutable` function
* Write tests
2024-12-18 11:32:02 -05:00

22 lines
529 B
Go

// Package paths contains a variety of helper functions responsible for
// computing paths to various things. This package should not depend on any
// other asdf packages.
package paths
import (
"strings"
)
// RemoveFromPath returns the PATH without asdf shims path
func RemoveFromPath(currentPath, pathToRemove string) string {
var newPaths []string
for _, fspath := range strings.Split(currentPath, ":") {
if fspath != pathToRemove {
newPaths = append(newPaths, fspath)
}
}
return strings.Join(newPaths, ":")
}