docs: clarify assert.Zero() is unrelated to encoding/json omitempty/omitzero#1903
Open
RichardHopperProGrammar wants to merge 2 commits into
Open
docs: clarify assert.Zero() is unrelated to encoding/json omitempty/omitzero#1903RichardHopperProGrammar wants to merge 2 commits into
RichardHopperProGrammar wants to merge 2 commits into
Conversation
assert.Zero uses reflect.Zero to compare against the zero value of a type. It does not use or check any IsZero() method, and is unrelated to encoding/json's omitempty or omitzero struct tags. This change adds documentation to assert.Zero() to prevent confusion and includes a test with an IsZero()-implementing struct to verify the behavior. Closes stretchr#1759
Collaborator
|
Your fix is related to an issue I raised You can mention it in your PR description |
ccoVeille
previously approved these changes
May 28, 2026
Author
|
Thanks @ccoVeille — updated the PR description to reference #1759 and added context about the confusion. Appreciate the link! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clarify that
assert.Zero()is unrelated toencoding/jsonomitempty/omitzeroSummary
Update the documentation for
assert.Zero()to explicitly clarify that it checks whether a value equals its zero value in Go, and is not related to Go 1.24+encoding/jsonomitemptyoromitzerosemantics.This is a common point of confusion — users expect
assert.Zero()to behave likejson.Marshalomitempty logic, but it simply checks equality against the type's zero value (== false,== "",== 0, etc.).Related
Changes
Zero()function with explicit note about json omitempty/omitzero distinction