2 Commits

Author SHA1 Message Date
2bf9323203 fixing false undefined error 2022-08-26 02:41:13 -04:00
7cba7d1117 Adding env.HasEnv for single-value env exist logic 2022-05-29 22:52:03 -04:00
2 changed files with 41 additions and 26 deletions

View File

@@ -118,3 +118,17 @@ func GetPidEnvMapNative(pid uint32) (envMap map[string]interface{}, err error) {
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
}

View File

@@ -20,13 +20,12 @@ package paths
import (
"errors"
`fmt`
`io/fs`
"fmt"
"io/fs"
"os"
"os/user"
"path/filepath"
`strings`
"strings"
// "syscall"
)
@@ -113,6 +112,8 @@ func MakeDirIfNotExist(path string) (err error) {
if !stat.Mode().IsDir() {
err = errors.New(fmt.Sprintf("path %v exists but is not a directory", locPath))
return
} else {
return
}
// This should probably never happen. Probably.