Skip to content

Commit

Permalink
only support name=value format, event for boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanor committed Sep 24, 2020
1 parent 984ec17 commit 23a2085
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ffenv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ffenv

import (
"bufio"
"fmt"
"io"
"strings"
)
Expand Down Expand Up @@ -31,12 +32,12 @@ func parse(prefix string, r io.Reader, set func(name, value string) error) error
index = strings.IndexRune(line, '=')
)
if index < 0 {
name, value = line, "true" // boolean option
} else {
name, value = strings.ToLower(line[:index]), line[index+1:]
name = strings.ReplaceAll(name, "_", "-")
return fmt.Errorf("wrong format in env file, must be: name=value")
}

name, value = strings.ToLower(line[:index]), line[index+1:]
name = strings.ReplaceAll(name, "_", "-")

if i := strings.Index(value, " #"); i >= 0 {
value = strings.TrimSpace(value[:i])
}
Expand Down

0 comments on commit 23a2085

Please sign in to comment.