-
-
Save artyom/d67e54449092b85bb95b to your computer and use it in GitHub Desktop.
Go flag supports both 'long' and 'short' options
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 ( | |
| "flag" | |
| "fmt" | |
| ) | |
| func main() { | |
| n := 42 | |
| flag.IntVar(&n, "num", n, "your number ('long' option)") | |
| flag.IntVar(&n, "n", n, "your number ('short' option)") | |
| flag.Parse() | |
| fmt.Println("your number is:", n) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment