import ( "github.com/simonleung8/flags" "fmt" ) func main() { fc := flags.NewFlagContext() fc.IntVar(&num, "num", 1, "an integer value") fc.Parse() fmt.Println(num) }
import ( "github.com/simonleung8/flags" "fmt" ) func main() { fc := flags.NewFlagContext() fc.Group("Input options") fc.StringVar(&infile, "infile", "", "input file") fc.StringVar(&intype, "intype", "txt", "input file type") fc.Group("Output options") fc.StringVar(&outfile, "outfile", "", "output file") fc.StringVar(&outtype, "outtype", "json", "output file type") fc.Parse() fmt.Printf("Input: %s (%s), Output: %s (%s)\n", infile, intype, outfile, outtype) }In this example, we create a new `FlagContext` and group related flags together using `fc.Group()`. We create an input group with flags for the input file and its type, and an output group with flags for the output file and its type. We then parse the command-line arguments using `fc.Parse()` and print the input and output file information. Overall, the `github.com.simonleung8.flags` package library in Go is a useful tool for handling command-line arguments and creating organized, flexible, and customizable command-line interfaces.