谢谢jimmykuu
还有个问题
使用xorm中的QuryString查询方法时
github.com/go-sql-driver/mysql
中的packets包报这个错
[mysql] 2017/09/22 17:30:30 packets.go:38: unexpected EOF
packets包相关代码:
// Read packet to buffer ‘data’
func (mc *mysqlConn) readPacket() ([]byte, error) {
var prevData []byte
for {
// read packet header
data, err := mc.buf.readNext(4)
if err != nil {
errLog.Print("readPacket:", data, err)
if cerr := mc.canceled.Value(); cerr != nil {
return nil, cerr
}
errLog.Print(err)//此处打印的错误
panic(err)
mc.Close()
return nil, driver.ErrBadConn
}
// packet length [24 bit]
pktLen := int(uint32(data[0]) | uint32(data[1])<<8 | uint32(data[2])<<16)
// check packet sync [8 bit]
if data[3] != mc.sequence {
if data[3] > mc.sequence {
return nil, ErrPktSyncMul
}
return nil, ErrPktSync
}
mc.sequence++
// packets with length 0 terminate a previous packet which is a
// multiple of (2^24)−1 bytes long
if pktLen == 0 {
// there was no previous packet
if prevData == nil {
errLog.Print(ErrMalformPkt)
mc.Close()
return nil, driver.ErrBadConn
}
return prevData, nil
}
// read packet body [pktLen bytes]
data, err = mc.buf.readNext(pktLen)
if err != nil {
if cerr := mc.canceled.Value(); cerr != nil {
return nil, cerr
}
errLog.Print(err)
mc.Close()
return nil, driver.ErrBadConn
}
// return data if this was the last packet
if pktLen < maxPacketSize {
// zero allocations for non-split packets
if prevData == nil {
return data, nil
}
return append(prevData, data...), nil
}
prevData = append(prevData, data...)
}
}