package main import ( "fmt" "github.com/spf13/pflag" ) func main() { fs := pflag.NewFlagSet("app", pflag.ExitOnError) var value int64 fs.Int64Var(&value, "val", 0, "a 64-bit integer value") fs.Parse([]string{"--val", "1234567890123"}) fmt.Println(value) // Output: 1234567890123 }
package main import ( "fmt" "github.com/spf13/pflag" ) func main() { fs := pflag.NewFlagSet("app", pflag.ExitOnError) var values []int64 fs.Int64SliceVar(&values, "vals", []int64{}, "a list of 64-bit integer values") fs.Parse([]string{"--vals", "123,456,789"}) fmt.Println(values) // Output: [123 456 789] }In this example, we use the Int64SliceVar method to define a flag named "vals" which accepts a list of 64-bit integers. We then parse a command-line argument for the flag and print its values. Overall, the "github.com/spf13/pflag" package library is useful for handling command-line arguments in Go programs, and the Int64Var method is particularly useful for working with 64-bit integers.