February 2018
Intermediate to advanced
340 pages
9h 43m
English
package main import ( "flag" "fmt" "log" "os" "strings" ) // Custom type need to implement // flag.Value interface to be able to // use it in flag.Var function. type ArrayValue []string func (s *ArrayValue) String() string { return fmt.Sprintf("%v", *s) } func (a *ArrayValue) Set(s string) error { *a = strings.Split(s, ",") return nil } func main() { // Extracting flag values with methods returning pointers retry := flag.Int("retry", -1, "Defines max retry count") // Read the flag using the XXXVar function. // In this case the variable must be defined // prior to the flag. var logPrefix ...Read now
Unlock full access