Skip to content

fix: stop GetIP erroring when the IP flag has a nil default#479

Closed
leno23 wants to merge 1 commit into
spf13:masterfrom
leno23:fix/getip-nil-default-478
Closed

fix: stop GetIP erroring when the IP flag has a nil default#479
leno23 wants to merge 1 commit into
spf13:masterfrom
leno23:fix/getip-nil-default-478

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 26, 2026

Summary

Fixes #478
Fixes #351

When an IP flag defaults to nil, GetIP round-trips through Value.String() and receives "<nil>", which ipConv rejected. Set("") already treats empty input as "no IP"; this mirrors that on the read side by returning (net.IP(nil), nil) for "" and "<nil>".

Test plan

  • Added TestGetIPNilDefault covering IP and IPVar with a nil default
  • go test ./...

Made with Cursor

When an IP flag defaults to nil, Value.String() round-trips as "<nil>"
and ipConv rejected it. Treat empty and "<nil>" as a nil net.IP, matching
Set("") behavior.

Fixes spf13#478.
Fixes spf13#351.

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant
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.


wuyangfan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@tomasaschan
Copy link
Copy Markdown
Collaborator

@leno23 if you don't sign the CLA I will implement automation that automatically closes any PRs from you. Please stop spamming.

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