1
0
mirror of https://github.com/prometheus/node_exporter.git synced 2026-02-06 00:45:19 +01:00

skip null bytes at the end of strings

Signed-off-by: ston1th <ston1th@giftfish.de>
This commit is contained in:
ston1th
2020-09-01 14:09:41 +02:00
parent 26bd6bf99d
commit bdba65df16

View File

@@ -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