Node_Exporter/vendor/github.com/mdlayher/netlink/nlenc/string.go
2017-01-10 11:29:00 -05:00

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