import ( "github.com/cloudfoundry/cli/flags" "fmt" ) func main() { flagContext := flags.New() stringFlag := flagContext.String("name", "John", "Specify your name") flagContext.Parse() fmt.Println("Hello, " + *stringFlag + "!") }
import ( "github.com/cloudfoundry/cli/flags" "fmt" ) func main() { flagContext := flags.New() intFlag := flagContext.Int("count", 1, "Specify number of times to execute") flagContext.Parse() for i := 1; i <= *intFlag; i++ { fmt.Println("Executing task", i) } }This program creates a flag context and adds an integer flag with a default value of 1. When the user runs the program with the `-count` flag, the FlagContext type will automatically parse and retrieve the value of that flag. In both examples, the `FlagContext` package library is used to create a flag context and add flags to it. The parsed values of the flags are then retrieved using the corresponding getter methods provided by the package.