From 2bd25f6c675569d859808bd28d2cf70fc270e4a7 Mon Sep 17 00:00:00 2001
From: Rafal Jeczalik <rafal@rjk.io>
Date: Fri, 8 Apr 2022 00:25:28 +0200
Subject: [PATCH] env: trim excessive quotes from strings

---
 format.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/format.go b/format.go
index 762adb5..5d36c7d 100644
--- a/format.go
+++ b/format.go
@@ -53,7 +53,13 @@ func (c *envCodec) marshal(v interface{}) ([]byte, error) {
 	)
 
 	for _, k := range keys {
-		fmt.Fprintf(&buf, "%s%s=%q\n", p, strings.ToUpper(k), envs[k])
+		v := fmt.Sprintf("%q", envs[k])
+
+		if _, ok := envs[k].(string); ok {
+			v = strings.Trim(v, `"`)
+		}
+
+		fmt.Fprintf(&buf, "%s%s=%s\n", p, strings.ToUpper(k), v)
 	}
 
 	return buf.Bytes(), nil