Last active
March 2, 2019 19:55
-
-
Save craicoverflow/e79ed163b202ed12f664ceafd93484e4 to your computer and use it in GitHub Desktop.
Accessing and printing an environment variable value in Go
This file contains hidden or 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