GetStringSlice returns a config value as a string slice.
(ns, key string)
| 423 | |
| 424 | // GetStringSlice returns a config value as a string slice. |
| 425 | func (c *LiveConfig) GetStringSlice(ns, key string) ([]string, error) { |
| 426 | nskey := nskey(ns, key) |
| 427 | val := viper.GetStringSlice(nskey) |
| 428 | |
| 429 | if isRequired(nskey) && emptyStringSlice(val) { |
| 430 | return nil, NewMissingArgsErr(nskey) |
| 431 | } |
| 432 | |
| 433 | out := []string{} |
| 434 | for _, item := range viper.GetStringSlice(nskey) { |
| 435 | item = strings.TrimPrefix(item, "[") |
| 436 | item = strings.TrimSuffix(item, "]") |
| 437 | |
| 438 | list := strings.Split(item, ",") |
| 439 | for _, str := range list { |
| 440 | if str == "" { |
| 441 | continue |
| 442 | } |
| 443 | out = append(out, str) |
| 444 | } |
| 445 | } |
| 446 | return out, nil |
| 447 | } |
| 448 | |
| 449 | // GetStringSliceIsFlagSet returns a config value as a string slice and a bool representing the existence of the flag. |
| 450 | func (c *LiveConfig) GetStringSliceIsFlagSet(ns, key string) ([]string, bool, error) { |
no test coverage detected