package main import ( "fmt" "flag" ) func main() { fs := flag.NewFlagSet("example", flag.ExitOnError) var value int64 fs.Int64Var(&value, "example", 5, "an example int64 flag") fs.Parse([]string{"-example=10"}) fmt.Println("The value of example flag is:", value) }
package main import ( "fmt" "flag" ) func main() { fs := flag.NewFlagSet("example", flag.ExitOnError) var value int64 fs.Int64Var(&value, "example", 5, "an example int64 flag") fs.Parse([]string{"-example", "abc"}) fmt.Println("The value of example flag is:", value) }In this example, the Parse function is called with an invalid value for the flag "example" ("abc" instead of an integer). This will cause the program to exit with an error message because the flag value cannot be converted to an int64.