Node_Exporter/vendor/github.com/mdlayher/netlink/nlenc/string.go

15 lines
337 B
Go
Raw Normal View History

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}))
}