package matcher type Packet struct { Buffer []byte Len int } func (p *Packet) Valid() bool { if nil == p.Buffer || 0 == p.Len { return false } return true } func (p *Packet) Bytes() []byte { if p.Valid() { return p.Buffer[:p.Len] } return nil } func NewPacket(buf []byte, len int) *Packet { return &Packet{ Buffer: buf, Len: len, } }