Created
March 5, 2020 18:53
-
-
Save alexellis/ec11526dac477b2fcad5e00925cc0286 to your computer and use it in GitHub Desktop.
go-hello-flags-env.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 ( | |
"flag" | |
"fmt" | |
"os" | |
) | |
func main() { | |
var printUser bool | |
flag.BoolVar(&printUser, "print-user", true, "Print a name if set to true") | |
flag.Parse() | |
user := os.Getenv("USER") | |
if printUser { | |
fmt.Printf("Hello %s\n", user) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment