mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-01-07 00:22:17 +01:00
0e77317955
* github.com/ema/qdisc * github.com/mdlayher/genetlink * github.com/mdlayher/wifi Signed-off-by: Ben Kochie <superq@gmail.com>
19 lines
585 B
Go
19 lines
585 B
Go
package nlenc
|
|
|
|
import "bytes"
|
|
|
|
// Bytes returns a null-terminated byte slice with the contents of s.
|
|
func Bytes(s string) []byte {
|
|
return append([]byte(s), 0x00)
|
|
}
|
|
|
|
// String returns a string with the contents of b from a null-terminated
|
|
// byte slice.
|
|
func String(b []byte) string {
|
|
// If the string has more than one NULL terminator byte, we want to remove
|
|
// all of them before returning the string to the caller; hence the use of
|
|
// strings.TrimRight instead of strings.TrimSuffix (which previously only
|
|
// removed a single NULL).
|
|
return string(bytes.TrimRight(b, "\x00"))
|
|
}
|