github.com/kjdelisle/consul@v1.4.5/command/flags/flag_slice_value.go (about)

     1  package flags
     2  
     3  import "strings"
     4  
     5  // AppendSliceValue implements the flag.Value interface and allows multiple
     6  // calls to the same variable to append a list.
     7  type AppendSliceValue []string
     8  
     9  func (s *AppendSliceValue) String() string {
    10  	return strings.Join(*s, ",")
    11  }
    12  
    13  func (s *AppendSliceValue) Set(value string) error {
    14  	if *s == nil {
    15  		*s = make([]string, 0, 1)
    16  	}
    17  
    18  	*s = append(*s, value)
    19  	return nil
    20  }