代码拉取完成,页面将自动刷新
/*
* go-mysqlstack
* xelabs.org
*
* Copyright (c) XeLabs
* Copyright 2016 The Go-MySQL-Driver Authors. All rights reserved.
* GPL License
*
*/
package packet
import (
"io"
"net"
"time"
)
var _ net.Conn = &MockConn{}
// MockConn used to mock a net.Conn for testing purposes.
type MockConn struct {
laddr net.Addr
raddr net.Addr
data []byte
closed bool
read int
}
// NewMockConn creates new mock connection.
func NewMockConn() *MockConn {
return &MockConn{}
}
// Read implements the net.Conn interface.
func (m *MockConn) Read(b []byte) (n int, err error) {
// handle the EOF
if len(m.data) == 0 {
err = io.EOF
return
}
n = copy(b, m.data)
m.read += n
m.data = m.data[n:]
return
}
// Write implements the net.Conn interface.
func (m *MockConn) Write(b []byte) (n int, err error) {
m.data = append(m.data, b...)
return len(b), nil
}
// Datas implements the net.Conn interface.
func (m *MockConn) Datas() []byte {
return m.data
}
// Close implements the net.Conn interface.
func (m *MockConn) Close() error {
m.closed = true
return nil
}
// LocalAddr implements the net.Conn interface.
func (m *MockConn) LocalAddr() net.Addr {
return m.laddr
}
// RemoteAddr implements the net.Conn interface.
func (m *MockConn) RemoteAddr() net.Addr {
return m.raddr
}
// SetDeadline implements the net.Conn interface.
func (m *MockConn) SetDeadline(t time.Time) error {
return nil
}
// SetReadDeadline implements the net.Conn interface.
func (m *MockConn) SetReadDeadline(t time.Time) error {
return nil
}
// SetWriteDeadline implements the net.Conn interface.
func (m *MockConn) SetWriteDeadline(t time.Time) error {
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。