Length-Based Frame Stream En-/Decoding in Go
You may consider to use binary.Read. I find this more readable and self documented. See this example.

var len uint16
err := binary.Read(buf, binary.LittleEndian, &amp;len)


The writing part:

len := uint16(len(p))
err := binary.Write(buf, binary.LittleEndian, len)


Also don't forget to check that len(p) doesn't overflow uint16 (less than 65535).

Apart from that your code is fine.