package main import ( "flag" "fmt" ) var ( verbose = flag.Bool("verbose", false, "Set verbose mode") count = flag.Int("count", 0, "counter") ) func main() { flag.Parse() args := flag.Args() if len(args) < 1 { fmt.Println("Error: args <name> is required.") return } name := &args[0] fmt.Printf("verbose mode: %v, count: %d, name: %s\n", *verbose, *count, *name) } $ go run ex_flag.go --count 10 --verb