Skip to content

Instantly share code, notes, and snippets.

@sumjha
Created June 4, 2020 07:44
Show Gist options
  • Save sumjha/b7cd72e3b1b24139a18a5f459295b2bf to your computer and use it in GitHub Desktop.
Save sumjha/b7cd72e3b1b24139a18a5f459295b2bf to your computer and use it in GitHub Desktop.
Check if a environment variable is set in Go (Golang)
package main
import (
"fmt"
"os"
)
func main() {
val, present := os.LookupEnv("MyEnvVariable")
fmt.Printf("MyEnvVariable env variable present: %t\n", present)
fmt.Println(val)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment