retrun data slice with correct index

This commit is contained in:
suchj 2012-12-30 02:01:09 +08:00
parent 36ba74f0dc
commit af47a3228f

View File

@ -142,9 +142,9 @@ func (a *agent) unpack(data []byte) ([]byte, int, bool) {
total := l + common.PACKET_LEN total := l + common.PACKET_LEN
if total == tl { // data is what we want if total == tl { // data is what we want
return data, common.PACKET_LEN, true return data, common.PACKET_LEN, true
} else if total < tl { // data[:total] is what we want, data[total:] is the more } else if total < tl { // data[:total] is what we want, data[total:] is the more
a.in <- data[total:] a.in <- data[total:]
data = data[:total] data = data[start:total]
return data, common.PACKET_LEN, true return data, common.PACKET_LEN, true
} else { // ops! It won't be possible. } else { // ops! It won't be possible.
return nil, total - tl, false return nil, total - tl, false