Skip to content

fix: allow nil default IP flags in GetIP#483

Merged
tomasaschan merged 1 commit into
spf13:masterfrom
happysnaker:fix-nil-default-ip-getter
Jul 2, 2026
Merged

fix: allow nil default IP flags in GetIP#483
tomasaschan merged 1 commit into
spf13:masterfrom
happysnaker:fix-nil-default-ip-getter

Conversation

@happysnaker

Copy link
Copy Markdown

Summary

  • treat the zero-value string form of a nil net.IP flag as a nil result in GetIP()
  • keep IPVar(..., nil, ...) usable for optional IP flags without forcing callers through parse errors
  • add regression coverage for nil default IP flags

Motivation

When an IP flag is declared with a nil default value, the internal string form becomes <nil>. GetIP() currently passes that through ipConv, which tries to parse it as a literal IP string and returns an error. This makes optional IP flags awkward to model when callers want an actual nil default.

This change keeps the existing parsing behavior for user-provided values, but lets untouched nil defaults round-trip cleanly through GetIP().

Closes #351

@CLAassistant

CLAassistant commented Jul 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@happysnaker

Copy link
Copy Markdown
Author

Quick status update: the CLA check is green now, so the PR is no longer blocked on contributor-signature state.

Current intent stays the same: make nil-default IP flags round-trip cleanly through GetIP() instead of failing on the internal <nil> string form.

@tomasaschan tomasaschan merged commit 7475282 into spf13:master Jul 2, 2026
8 checks passed
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.

Support for nil default value in IP flag

3 participants