You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: collection.go
    path of file: ./repos/tiedot/data
    
    the code of the file until where you have to start completion: // Collection data file contains document data.
//
// Every document has a binary header and UTF-8 text content.
//
// Documents are inserted one after another, and occupies 2x original document
// size to leave room for future updates.
//
// Deleted documents are marked as deleted and the space is irrecoverable until
// a "scrub" action (in DB logic) is carried out.
//
// When update takes place, the new document may overwrite original document if
// there is enough space, otherwise the original document is marked as deleted
// and the updated document is inserte
    
func (col *Collection) Insert(data []byte) (id int, err error) {
	room := len(data) << 1
	if room > col.DocMaxRoom {
		return 0, dberr.New(dberr.ErrorDocTooLarge, col.DocMaxRoom, room)
	}
	id = col.Used
	docSize := DocHeader + room
	if err = col.EnsureSize(docSize); err != nil {
		return
	}
	col.Used += docSize
	// Write validity, room, document data and padding
	col.Buf[id] = 1
	binary.PutVarint(col.Buf[id+1:id+11], int64(room))
	copy(col.Buf[id+DocHeader:col.Used], data)
	for padding := id + DocHeader + len(data); padding < col.Used; padding += col.LenPadding {
		copySize := col.LenPadding
		if padding+col.LenPadding >= col.Used {
			copySize = col.Used - padding
		}
		copy(col.Buf[padding:padding+copySize], col.Padding)
	}
	return
}