[Golang] Check if Environment Variable Exist
Use os.LookupEnv in Go standard library to check if an environment variable exists. the following is an method to help you check:
import (
"os"
)
func isEnvExist(key string) bool {
if _, ok := os.LookupEnv(key); ok {
return true
}
return false
}
You can run example code by the following link:
References:
[1] |