import "github.com/spf13/pflag" var ( flag1 = pflag.String("flag1", "", "help message") flag2 = pflag.String("flag2", "", "help message") flag3 = pflag.String("flag3", "", "help message") ) func main() { pflag.Parse() // Access flag values through their variables fmt.Println("flag1:", *flag1) fmt.Println("flag2:", *flag2) fmt.Println("flag3:", *flag3) }
var count int pflag.IntVar(&count, "count", 0, "number of items to process") func main() { pflag.Parse() // Access the value of the count flag through the variable fmt.Println("count:", count) }Overall, the github.com.spf13.pflag package library provides a flexible and powerful set of utilities for parsing command-line flags in Go programs.