adding func to get PATH var
This commit is contained in:
parent
8337d9f973
commit
cf50c65438
@ -6,10 +6,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Strings are, apparently, cast as pointers. A lot of the ptr ref/deref below is redundant.
|
var err error
|
||||||
// Regardless, future-prooofing.
|
|
||||||
|
|
||||||
func ExpandHome(path *string) error {
|
func ExpandHome(path *string) error {
|
||||||
// Props to this guy.
|
// Props to this guy.
|
||||||
@ -27,6 +27,17 @@ func ExpandHome(path *string) error {
|
|||||||
return nil
|
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 {
|
func MakeDirIfNotExist(path *string) error {
|
||||||
exists, stat, err := RealPathExistsStat(path)
|
exists, stat, err := RealPathExistsStat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user