Skip to content

Commit 2bfdb0a

Browse files
committed
Add omitzero mention in README
1 parent 51fad25 commit 2bfdb0a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ It is important to make sure your JSON expression returns a value that has a typ
279279

280280
### Model and DTO recommendations
281281

282-
- Use `json:",omitempty"` on all DTO fields.
283-
- *Note: using `omitempty` on slices will remove them from the json result if they are not nil and empty. There is currently no solution to this problem using the standard json package.*
282+
- Use `json:",omitempty"` on all DTO fields. Use `json:",omitzero"` for struct fields like `time.Time`, slices or maps.
284283
- Don't include the foreign keys in the DTO.
285284
- Use `*null.Time` from the [`gopkg.in/guregu/null.v4`](https://github.com/guregu/null) library instead of `sql.NullTime`.
286285
- Always specify `gorm:"foreignKey"`, otherwise falls back to "ID".

0 commit comments

Comments
 (0)