Skip to content

Treat empty numeric environment values as zero - #301

Open
rupayon123 wants to merge 1 commit into
alexflint:masterfrom
rupayon123:contribution/empty-numeric-env-20260923
Open

rupayon123 wants to merge 1 commit into
alexflint:masterfrom
rupayon123:contribution/empty-numeric-env-20260923

Conversation

@rupayon123

Copy link
Copy Markdown

Fixes #160.

An explicitly empty environment variable currently reaches strconv.ParseInt and causes parsing to fail for an integer field. This treats an empty value as numeric zero for signed, unsigned, and floating-point fields, including pointers and named numeric types. It remains present, so it overrides a declared default; a command-line value can still override it later.

The earlier #169 was closed after review identified a *string regression. This change keeps empty strings on the existing parse path and tests *string with absent, empty, and non-empty environment values. The numeric regression fails on unmodified master and passes here.

Validation: go test ./... -count=1, go test -race ./... -count=1, go vet ./..., and git diff --check pass locally. The upstream Go 1.20–1.22 matrix has not run yet.

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.

int with arg:"env" results in strconv.ParseInt: parsing "": invalid syntax if environment variable is empty

1 participant