Created
May 26, 2017 13:27
-
-
Save jintao-zero/029c863c3c73dcd80c6bbf4cf32eb063 to your computer and use it in GitHub Desktop.
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" | |
) | |
var name = flag.String("name", "", "the name ") | |
var age int | |
func init() { | |
flag.IntVar(&age, "age", 0, "the age") | |
} | |
func main() { | |
flag.Parse() | |
if len(*name) == 0 { | |
flag.Usage() | |
return | |
} | |
fmt.Printf("name: %s age:%d", *name, age) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment