Browse Source

skip null bytes at the end of strings

Signed-off-by: ston1th <ston1th@giftfish.de>
pull/1774/head
ston1th 4 years ago
parent
commit
bdba65df16
  1. 10
      collector/sysctl_openbsd_amd64.go

10
collector/sysctl_openbsd_amd64.go

@ -20,11 +20,15 @@ import (
)
func int8ToString(a []int8) string {
b := make([]byte, len(a))
buf := make([]byte, len(a))
for i, v := range a {
b[i] = byte(v)
if byte(v) == 0 {
buf = buf[:i]
break
}
buf[i] = byte(v)
}
return string(b)
return string(buf)
}
// unix._C_int

Loading…
Cancel
Save