Skip to content

Commit

Permalink
refmt: fix transformations for env codec
Browse files Browse the repository at this point in the history
  • Loading branch information
rjeczalik committed Apr 8, 2022
1 parent 9671524 commit 6b3c6a2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions format.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,17 @@ func (c *envCodec) marshal(v interface{}) ([]byte, error) {
return nil, errors.New("envCoded: cannot marshal non-object value")
}

object.Walk(m, transform(true))

var (
p = *c.prefix
envs = object.Flatten(m, "_")
keys = object.Keys(envs)
buf bytes.Buffer
)

for _, key := range keys {
v := envs[key]
k, opts := parseOptions(key)
v = executeOptions(v, opts, true)

fmt.Fprintf(&buf, "%s%s=%s\n", p, strings.ToUpper(k), v)
for _, k := range keys {
fmt.Fprintf(&buf, "%s%s=%s\n", p, strings.ToUpper(k), envs[k])
}

return buf.Bytes(), nil
Expand Down

0 comments on commit 6b3c6a2

Please sign in to comment.