status-go/vendor/github.com/elastic/gosigar/sigar_util.go
Andrea Maria Piana 36430257fd Upgrade geth
Point to the new fork of geth.
2021-07-20 10:57:38 +02:00

31 lines
662 B
Go

// Copyright (c) 2012 VMware, Inc.
package gosigar
import (
"bytes"
)
// byteListToString converts the raw byte arrays we get into a string. This is a bit of a process, as byte strings are normally []uint8
func byteListToString(raw []int8) string {
byteList := make([]byte, len(raw))
for pos, singleByte := range raw {
byteList[pos] = byte(singleByte)
if singleByte == 0 {
break
}
}
return string(bytes.Trim(byteList, "\x00"))
}
func chop(buf []byte) []byte {
return buf[0 : len(buf)-1]
}
// convertBytesToString trims null bytes and returns a string
func convertBytesToString(arr []byte) string {
return string(bytes.Trim(arr, "\x00"))
}