Skip to content

fix(dotenv): encode []string as CSV instead of Go bracket notation#2128

Open
lcensies wants to merge 1 commit into
spf13:masterfrom
lcensies:fix/dotenv-slice-roundtrip
Open

fix(dotenv): encode []string as CSV instead of Go bracket notation#2128
lcensies wants to merge 1 commit into
spf13:masterfrom
lcensies:fix/dotenv-slice-roundtrip

Conversation

@lcensies

Copy link
Copy Markdown

Bug description

fmt's %v on []string produces "[a b]" which gotenv reads back as a
literal string, breaking round-trip.

Example:

cfg.Set("Hosts", []string{"172.12.5.2:3434"})

Gets serialized to

HOSTS=[172.12.5.2:3434]

Which fails during backward deserialization

Fix

Serialize string list as csv-like format

+               case []string:
+                       valStr = strings.Join(v, ",")

@CLAassistant

CLAassistant commented May 14, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants