Skip to content

Commit b042b6d

Browse files
committed
types/events: use omitzero where appropriate
In these cases, omitempty doesn't really work so it is useless, but omitzero actually works. As a result, output of `runc events` may omit these fields if all they contain are zeroes. NOTE this might be a breaking change. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 2660265 commit b042b6d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

types/events.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ type CpuUsage struct {
7575
}
7676

7777
type Cpu struct {
78-
Usage CpuUsage `json:"usage,omitempty"`
79-
Throttling Throttling `json:"throttling,omitempty"`
78+
Usage CpuUsage `json:"usage,omitzero"`
79+
Throttling Throttling `json:"throttling,omitzero"`
8080
PSI *PSIStats `json:"psi,omitempty"`
8181
}
8282

@@ -103,10 +103,10 @@ type MemoryEntry struct {
103103

104104
type Memory struct {
105105
Cache uint64 `json:"cache,omitempty"`
106-
Usage MemoryEntry `json:"usage,omitempty"`
107-
Swap MemoryEntry `json:"swap,omitempty"`
108-
Kernel MemoryEntry `json:"kernel,omitempty"`
109-
KernelTCP MemoryEntry `json:"kernelTCP,omitempty"`
106+
Usage MemoryEntry `json:"usage,omitzero"`
107+
Swap MemoryEntry `json:"swap,omitzero"`
108+
Kernel MemoryEntry `json:"kernel,omitzero"`
109+
KernelTCP MemoryEntry `json:"kernelTCP,omitzero"`
110110
Raw map[string]uint64 `json:"raw,omitempty"`
111111
PSI *PSIStats `json:"psi,omitempty"`
112112
}

0 commit comments

Comments
 (0)