Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy Markdown
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.

- Complex types
- `map`, `slice`, `struct`
- Nested types
Expand Down Expand Up @@ -46,7 +47,7 @@ type Sample struct {
Name string `default:"John Smith"`
Age int `default:"27"`
Gender Gender `default:"m"`
Working bool `default:"true"`
Working *bool `default:"true"`

SliceInt []int `default:"[1, 2, 3]"`
SlicePtr []*int `default:"[1, 2, 3]"`
Expand Down