The specification of "copy", the builtin function per https://pkg.go.dev/builtin#copy, says that it returns the minimum of len(src) and len(dst) when invoked as: copy(dst, src) of which the prior code blindly assumed that everytime that copy is invoked that the buffer provided had enough size to accomodate the contents of *.MarshalTo but this isn't true at all if len(data) is less than the values of .Marshal()