Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'multi_string_flag.go')
-rw-r--r--multi_string_flag.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/multi_string_flag.go b/multi_string_flag.go
index b8e85991..1dd76b28 100644
--- a/multi_string_flag.go
+++ b/multi_string_flag.go
@@ -1,9 +1,12 @@
package main
import (
+ "errors"
"strings"
)
+var errMultiStringSetEmptyValue = errors.New("set value cannot be empty")
+
// MultiStringFlag implements the flag.Value interface and allows a string flag
// to be specified multiple times on the command line.
//
@@ -17,6 +20,9 @@ func (s *MultiStringFlag) String() string {
// Set appends the value to the list of parameters
func (s *MultiStringFlag) Set(value string) error {
+ if value == "" {
+ return errMultiStringSetEmptyValue
+ }
*s = append(*s, value)
return nil
}
@@ -24,9 +30,6 @@ func (s *MultiStringFlag) Set(value string) error {
// Split each flag
func (s *MultiStringFlag) Split() (result []string) {
for _, str := range *s {
- if str == "" {
- continue
- }
result = append(result, strings.Split(str, ",")...)
}