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

add test for bool default not to overwrite existing value #50

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robbkidd
Copy link

@robbkidd robbkidd commented Jan 18, 2024

Demonstrates the issue in #49 that that a default of true will override an existing value of false for bool fields.

Demonstrates that that a default of true will override an existing value
of false for bool fields.
func TestOverrideDefaultTrueBoolToFalse(t *testing.T) {
type example struct {
BoolTrue bool `default:"true"`
BoolPointerTrue *bool `default:"true"`
Copy link
Author

Choose a reason for hiding this comment

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

This is the workaround to have a field that defaults to true that a user can still set to false and not have defaults.Set() change it back to true.

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.

None yet

1 participant