summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/parse.go b/parse.go
index 94c0a89..13e8195 100644
--- a/parse.go
+++ b/parse.go
@@ -441,13 +441,17 @@ func (p *Parser) captureEnvVars(specs []*spec, wasPresent map[*spec]bool) error
if spec.cardinality == multiple {
// expect a CSV string in an environment
// variable in the case of multiple values
- values, err := csv.NewReader(strings.NewReader(value)).Read()
- if err != nil {
- return fmt.Errorf(
- "error reading a CSV string from environment variable %s with multiple values: %v",
- spec.env,
- err,
- )
+ var values []string
+ var err error
+ if len(strings.TrimSpace(value)) > 0 {
+ values, err = csv.NewReader(strings.NewReader(value)).Read()
+ if err != nil {
+ return fmt.Errorf(
+ "error reading a CSV string from environment variable %s with multiple values: %v",
+ spec.env,
+ err,
+ )
+ }
}
if err = setSliceOrMap(p.val(spec.dest), values, !spec.separate); err != nil {
return fmt.Errorf(