Skip to content

Instantly share code, notes, and snippets.

@jintao-zero
Created May 26, 2017 13:27
Show Gist options
  • Save jintao-zero/029c863c3c73dcd80c6bbf4cf32eb063 to your computer and use it in GitHub Desktop.
Save jintao-zero/029c863c3c73dcd80c6bbf4cf32eb063 to your computer and use it in GitHub Desktop.
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