Codebase list golang-bindata / 0806bccb-010a-4070-84cb-8714a6a7a184/main go-bindata / AppendSliceValue.go
0806bccb-010a-4070-84cb-8714a6a7a184/main

Tree @0806bccb-010a-4070-84cb-8714a6a7a184/main (Download .tar.gz)

AppendSliceValue.go @0806bccb-010a-4070-84cb-8714a6a7a184/mainraw · history · blame

package main

import "strings"

// borrowed from https://github.com/hashicorp/serf/blob/master/command/agent/flag_slice_value.go

// AppendSliceValue implements the flag.Value interface and allows multiple
// calls to the same variable to append a list.
type AppendSliceValue []string

func (s *AppendSliceValue) String() string {
	return strings.Join(*s, ",")
}

func (s *AppendSliceValue) Set(value string) error {
	if *s == nil {
		*s = make([]string, 0, 1)
	}

	*s = append(*s, value)
	return nil
}