Reading Environment Variables in Go
Use os.Getenv() to read an environment variable: package main import ( “fmt” “os” ) func main() { val := os.Getenv(“MY_VAR”) fmt.Println(val) } os.Getenv() returns an empty string if the variable doesn’t exist. This means you can’t distinguish between an unset variable and one explicitly set to an empty string. Checking if a variable exists To…
