mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-18 14:40:26 +01:00
20 lines
486 B
Go
20 lines
486 B
Go
|
package envutil
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
// GetenvBool retrieves the value of the environment variable named by the key,
|
||
|
// attempts to convert the value to bool type and returns the result. In order
|
||
|
// for conversion to succeed, the value must be any value supported by
|
||
|
// strconv.ParseBool() function, otherwise the function will return false.
|
||
|
func GetenvBool(key string) bool {
|
||
|
s := os.Getenv(key)
|
||
|
b, err := strconv.ParseBool(s)
|
||
|
if err != nil {
|
||
|
return false
|
||
|
}
|
||
|
return b
|
||
|
}
|