Skip to content

Commit a06dc1d

Browse files
committed
feat: add a hex field to Id types
Helps address issues brought up in nix-community/nixos-facter-modules#58 by introducing an additional hex field in the Id type. Eventually, we can make this a breaking change by removing the value field and incrementing the report version. This is a chance to test out how we can introduce breaking changes, whilst allowing module authors time to update. Closes #141 Signed-off-by: Brian McGee <[email protected]>
1 parent a43dbbe commit a06dc1d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/hwinfo/id.go

+7
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,18 @@ func (i Id) MarshalJSON() ([]byte, error) {
7373
case IdTagSpecial:
7474
return json.Marshal(i.Name)
7575
default:
76+
var hex string
77+
if i.Type > 0 {
78+
hex = fmt.Sprintf("%04x", i.Value)
79+
}
80+
7681
return json.Marshal(struct {
7782
Name string `json:"name,omitempty"`
83+
Hex string `json:"hex,omitempty"`
7884
Value uint16 `json:"value"`
7985
}{
8086
Name: i.Name,
87+
Hex: hex,
8188
Value: i.Value,
8289
})
8390
}

0 commit comments

Comments
 (0)