packageipnsimport"io"typeWriteAtBufinterface{io.WriterAtBytes()[]byte}typewriterAtstruct{buf[]byte}funcNewWriterAtFromBytes(b[]byte)WriteAtBuf{return&writerAt{b}}// TODO: make this better in the future, this is just a quick hack for nowfunc(wa*writerAt)WriteAt(p[]byte,offint64)(int,error){ifoff+int64(len(p))>int64(len(wa.buf)){wa.buf=append(wa.buf,make([]byte,(int(off)+len(p))-len(wa.buf))...)}copy(wa.buf[off:],p)returnlen(p),nil}func(wa*writerAt)Bytes()[]byte{returnwa.buf}