Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update README to document *bool behavior #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fchikwekwe
Copy link

bool values that are unset (zero value is false) or have been set to false are indistinguishable from one another. As a result, bool values with default true that are set to false get overriden by the defaults library.

If the user declares a *bool in their struct, then there are three possible setting for boolean: true, false and unset.

Closes #49
Related to #50

Copy link

codecov bot commented Jan 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5220e08) 95.97% compared to head (99f0f31) 95.97%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #51   +/-   ##
=======================================
  Coverage   95.97%   95.97%           
=======================================
  Files           2        2           
  Lines         149      149           
=======================================
  Hits          143      143           
  Misses          3        3           
  Partials        3        3           

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

@@ -12,6 +12,7 @@ Initialize structs with default values
- Scalar types
- `int/8/16/32/64`, `uint/8/16/32/64`, `float32/64`
- `uintptr`, `bool`, `string`
- `bool` values declared as a `*bool` allow for an unset boolean type. This helps distinguish the case where a default true bool is set to `false`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not exclusive to bool values.
Any scalar type can't distinguish an unspecified value from its zero value.
For int, an unspecified value means 0; For string, an empty string ("").

If we want to indicate this behavior in README, we might as well do with technicalities.

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.

Struct tag boolean values are not parsed properly when specified with double quotes
2 participants