mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +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 (
|
import (
|
||||||
goflag "flag"
|
goflag "flag"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -45,7 +46,10 @@ func (s *StringSlice) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StringSlice) Set(val string) error {
|
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 = make([]string, 0)
|
||||||
}
|
}
|
||||||
*s.value = append(*s.value, val)
|
*s.value = append(*s.value, val)
|
||||||
|
Loading…
Reference in New Issue
Block a user