Skip to content

Commit

Permalink
🎨 returning nil instead of empty struct in Info
Browse files Browse the repository at this point in the history
  • Loading branch information
juanhuttemann committed Aug 14, 2020
1 parent 18d1219 commit 21d5e0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions memdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func Info() ([]Memory, error) {
var mems []Memory
stream, _, err := smbios.Stream()
if err != nil {
return []Memory{}, err
return nil, err
}

defer stream.Close()

d := smbios.NewDecoder(stream)
ss, err := d.Decode()
if err != nil {
return []Memory{}, err
return nil, err
}

for _, s := range ss {
Expand Down
7 changes: 7 additions & 0 deletions memdev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ func TestInfo(t *testing.T) {
t.Fatalf("Expected Memory >= 0, but got %d", len(memInfo))
}
}

func TestSlots(t *testing.T) {
_, err := Slots()
if err != nil {
t.Fatalf("Expected nil error but got %v", err)
}
}

0 comments on commit 21d5e0c

Please sign in to comment.