Skip to content

Commit 96c90e0

Browse files
committed
Switch optional fields to require omitempty
1 parent 69b4e2c commit 96c90e0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.golangci.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ linters:
2525
preference: WhenRequired
2626
policy: SuggestFix
2727
omitEmpty:
28-
# Ignore missing omitempty so that we can omit the omitempty for discoverability.
29-
# Discoverability is for configuration APIs, generally singletons.
30-
# Refer to the API conventions for when to use discoverability (not our default stance).
31-
policy: Ignore
28+
# This will force omitempty on optional fields.
29+
# This is in line with upstream guidance where optional fields should be omitted
30+
# from the serialized output unless they are non-zero.
31+
policy: SuggestFix
32+
omitzero:
33+
# This will force omitzero on optional struct fields.
34+
# This means they can be omitted correctly and prevents the need for pointers to structs.
35+
policy: SuggestFix
3236
requiredFields:
3337
pointers:
3438
# This will force pointers when the field is required, but only when the zero

0 commit comments

Comments
 (0)