Skip to content

Instantly share code, notes, and snippets.

@craicoverflow
Last active February 28, 2019 20:08
Show Gist options
  • Save craicoverflow/025290c6e61a5c58d12608d7c55a6d4b to your computer and use it in GitHub Desktop.
Save craicoverflow/025290c6e61a5c58d12608d7c55a6d4b to your computer and use it in GitHub Desktop.
Setting an environment variable in Go
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