diff --git a/paths/paths.go b/paths/paths.go index b007e20..7ebbd09 100644 --- a/paths/paths.go +++ b/paths/paths.go @@ -6,10 +6,10 @@ import ( "os" "os/user" "path/filepath" + "strings" ) -// Strings are, apparently, cast as pointers. A lot of the ptr ref/deref below is redundant. -// Regardless, future-prooofing. +var err error func ExpandHome(path *string) error { // Props to this guy. @@ -27,6 +27,17 @@ func ExpandHome(path *string) error { return nil } +func GetPathEnv() ([]string, error) { + paths := []string{} + for _, p := range strings.Split(os.Getenv("PATH"), ":") { + if err = RealPath(&p); err != nil { + return nil, err + } + paths = append(paths, p) + } + return paths, nil +} + func MakeDirIfNotExist(path *string) error { exists, stat, err := RealPathExistsStat(path) if err != nil {