import "flag" func main() { // define flags using flag package var name = flag.String("name", "world", "A name to say hello to") var age = flag.Int("age", 0, "The age of the person") flag.PrintDefaults() }
import "flag" func main() { // Define a new FlagSet fs := flag.NewFlagSet("myprogram", flag.ExitOnError) // Define flags using the FlagSet var name = fs.String("name", "world", "A name to say hello to") var age = fs.Int("age", 0, "The age of the person") fs.PrintDefaults() }In this example, we create a new FlagSet using `flag.NewFlagSet`, and define two flags using this new FlagSet (`name` and `age`). We then call `FlagSet.PrintDefaults()` to print out the default values of these flags. The package library for these examples is the standard `flag` package in Go.