Adding env.HasEnv for single-value env exist logic

This commit is contained in:
brent s. 2022-05-29 22:52:03 -04:00
parent ecea194c0f
commit 7cba7d1117
Signed by: bts
GPG Key ID: 8C004C2F93481F6B

View File

@ -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
}