Skip to content

Instantly share code, notes, and snippets.

@craicoverflow
Last active March 2, 2019 19:55
Accessing and printing an environment variable value in Go
package main
import (
"fmt"
"os"
)
func main() {
// Store the PATH environment variable in a variable
path, exists := os.LookupEnv("PATH")
if exists {
// Print the value of the environment variable
fmt.Print(path)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment