I have a slice of bytes to represent a null-terminated string with trailing garbage bytes.
I followed How can I convert a zero-terminated byte array to string?
s := string(byteArray[:n])
but it doesn't work
[54 49 0 101 0 0 0 0 64 31 1 0 0]
61e@
instead of just 61
I've also tried to trim the slice: bytes.Trim(buf[:], "\x00") same result.