Last active
March 2, 2019 19:55
Accessing and printing an environment variable value in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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