mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-25 11:49:58 +01:00
15 lines
337 B
Go
15 lines
337 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 {
|
||
|
return string(bytes.TrimSuffix(b, []byte{0x00}))
|
||
|
}
|