You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
592 B
Go

package binlog
func GenBinlogEventBytes(fh EventFixedHeader, fd EventFixedData, vd EventVariableData) ([]byte, error) {
eventLength := LOG_EVENT_FIXED_HEADER_LEN + len(fd.Bytes) + len(vd.Bytes)
fh.EventLength = uint(eventLength)
buf := make([]byte, eventLength)
intToBytes(fh.Timestamp, buf[0:4])
intToBytes(fh.EventType, buf[4:5])
intToBytes(fh.ServerId, buf[5:9])
uintToBytes(fh.EventLength, buf[9:13])
intToBytes(fh.NextPosition, buf[13:17])
intToBytes(fh.Flags, buf[17:19])
copy(buf[19:19+len(fd.Bytes)-1], fd.Bytes)
copy(buf[19+len(fd.Bytes):], vd.Bytes)
return buf, nil
}