Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
2bf9323203
|
|||
|
7cba7d1117
|
@@ -118,3 +118,17 @@ func GetPidEnvMapNative(pid uint32) (envMap map[string]interface{}, err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
HasEnv is much like os.LookupEnv, but only returns a boolean for
|
||||||
|
if the environment variable key exists or not.
|
||||||
|
|
||||||
|
This is useful anywhere you may need to set a boolean in a func call
|
||||||
|
depending on the *presence* of an env var or not.
|
||||||
|
*/
|
||||||
|
func HasEnv(key string) (envIsSet bool) {
|
||||||
|
|
||||||
|
_, envIsSet = os.LookupEnv(key)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ package paths
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
`fmt`
|
"fmt"
|
||||||
`io/fs`
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
`strings`
|
"strings"
|
||||||
|
|
||||||
// "syscall"
|
// "syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -113,6 +112,8 @@ func MakeDirIfNotExist(path string) (err error) {
|
|||||||
if !stat.Mode().IsDir() {
|
if !stat.Mode().IsDir() {
|
||||||
err = errors.New(fmt.Sprintf("path %v exists but is not a directory", locPath))
|
err = errors.New(fmt.Sprintf("path %v exists but is not a directory", locPath))
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should probably never happen. Probably.
|
// This should probably never happen. Probably.
|
||||||
|
|||||||
Reference in New Issue
Block a user