Skip to content

Commit 2b20187

Browse files
Fix always reset YANG list container when unmarshaled into
1 parent f629ce1 commit 2b20187

File tree

1 file changed

+2
-4
lines changed
  • internal/provider/cisco/gnmiext/v2

1 file changed

+2
-4
lines changed

internal/provider/cisco/gnmiext/v2/list.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@ func (l *List[K, V]) UnmarshalJSON(data []byte) error {
8181
return fmt.Errorf("failed to unmarshal list: %w", err)
8282
}
8383

84-
// Initialize the map if needed
85-
if *l == nil {
86-
*l = make(List[K, V], len(slice))
87-
}
84+
// Initialize the map to an empty map with the appropriate capacity
85+
*l = make(List[K, V], len(slice))
8886

8987
// Convert slice to map using the Key() method
9088
for _, item := range slice {

0 commit comments

Comments
 (0)