Skip to content

feat: default to "," separator and RFC3339 time layout - #224

Merged
obalunenko merged 1 commit into
masterfrom
feat/option-defaults
Nov 15, 2026
Merged

obalunenko merged 1 commit into
masterfrom
feat/option-defaults

Conversation

@obalunenko

Copy link
Copy Markdown
Owner

Description

Stacked on #223: merge that first; GitHub will retarget this PR to master.

Without options, the zero Parameters made every slice and time.Time lookup fail:

Call Before
Env[[]string]("K"), K=a,b invalid value (empty separator)
Env[time.Time]("K"), K=2026-01-02T15:04:05Z parsing time ...: extra text (empty layout)

Now the separator defaults to "," and the layout to time.RFC3339. option.WithSeparator and option.WithTimeLayout still override them, and an explicitly empty separator is still an error.

The docs now say that EnvOrDefault returns the default for invalid values too, not only for unset ones, and point to Env to tell the two cases apart. The behavior of EnvOrDefault itself is unchanged. The same text is in the package doc, the option docs and the README.

Testing

  • go test -race ./... passes, with new cases for the default separator, the default layout, an explicit empty separator, and EnvOrDefault with the default separator.
  • Both golangci configs report 0 issues.

Possible failures/side-effects

This is a behavior change for calls without options:

  • Env for a slice or time.Time used to return an error and now returns the parsed value;
  • EnvOrDefault in the same case used to return the default and now returns the parsed value.

Code that relied on getting the default here had its environment variable ignored, which is most likely a bug on its side, but it belongs in the release notes. Release it as a minor version.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@9886d21). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             master      #224   +/-   ##
==========================================
  Coverage          ?   100.00%           
==========================================
  Files             ?         3           
  Lines             ?        99           
  Branches          ?         0           
==========================================
  Hits              ?        99           
  Misses            ?         0           
  Partials          ?         0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@obalunenko
obalunenko force-pushed the feat/option-defaults branch 2 times, most recently from 59eedab to 8991d67 Compare November 15, 2026 18:52
Base automatically changed from refactor/internal-parse to master November 15, 2026 18:56
Without options the zero Parameters made every slice and time.Time
lookup fail: an empty separator is rejected and time.Parse with an
empty layout matches nothing. Default the separator to "," and the
layout to time.RFC3339; the options still override them, and an
explicitly empty separator is still an error.

Behavior change: Env for a slice or time.Time without options used to
return an error and now returns the parsed value. EnvOrDefault in the
same case used to return the default and now returns the parsed value.

Document that EnvOrDefault returns the default for invalid values too,
not only for unset ones, and point to Env to tell them apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@obalunenko
obalunenko merged commit 8a2e8ae into master Nov 15, 2026
11 checks passed
@obalunenko
obalunenko deleted the feat/option-defaults branch November 15, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant