import ( "flag" "fmt" ) func main() { var flagVal string flagSet := flag.NewFlagSet("myFlagSet", flag.ExitOnError) flagSet.StringVar(&flagVal, "myFlag", "defaultVal", "description") // Custom behaviour when myFlag is set flagSet.Visit(func(f *flag.Flag) { if f.Name == "myFlag" { fmt.Println("myFlag was set to:", f.Value) } }) flagSet.Parse(os.Args[1:]) }In this example, we create a new FlagSet and add a custom string flag called "myFlag". We then use the Visit function to create a custom behaviour when the flag is set. In this case, we simply print out the value of the flag. Finally, we parse the command-line arguments using the FlagSet. This function allows for more advanced flag parsing and handling in Go, making it a useful tool for creating command-line interfaces and applications.