Last active
February 28, 2019 20:08
-
-
Save craicoverflow/025290c6e61a5c58d12608d7c55a6d4b to your computer and use it in GitHub Desktop.
Setting an environment variable 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() { | |
// Set the USERNAME environment variable to "MattDaemon" | |
os.Setenv("USERNAME", "MattDaemon") | |
// Get the USERNAME environment variable | |
username := os.Getenv("USERNAME") | |
// Prints out username environment variable | |
fmt.Print(username) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment