From f58f76cddd2d2b04757ff6db5a134d369243bd17 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 18 May 2024 23:06:56 +0900 Subject: [PATCH] add comments --- packets.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packets.go b/packets.go index e14dc95cf..ec62bbe38 100644 --- a/packets.go +++ b/packets.go @@ -131,7 +131,9 @@ func (mc *mysqlConn) writePacket(data []byte) error { } return err } - if n != size+4 { + if n != 4+size { + // io.Writer(b) must return a non-nil error if it cannot write len(b) bytes. + // The io.ErrShortWrite error is used to indicate that this rule has not been followed. mc.cleanup() return io.ErrShortWrite } @@ -142,7 +144,6 @@ func (mc *mysqlConn) writePacket(data []byte) error { } pktLen -= size data = data[size:] - continue } }