mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
update string_slice_flag add nil judgment
This commit is contained in:
parent
c9414c2bba
commit
abf6584322
@ -18,6 +18,7 @@ package flag
|
||||
|
||||
import (
|
||||
goflag "flag"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
@ -45,7 +46,10 @@ func (s *StringSlice) String() string {
|
||||
}
|
||||
|
||||
func (s *StringSlice) Set(val string) error {
|
||||
if s.value == nil || !s.changed {
|
||||
if s.value == nil {
|
||||
return fmt.Errorf("no target (nil pointer to []string)")
|
||||
}
|
||||
if *s.value == nil || !s.changed {
|
||||
*s.value = make([]string, 0)
|
||||
}
|
||||
*s.value = append(*s.value, val)
|
||||
|
Loading…
Reference in New Issue
Block a user