The error "slice bounds out of range" appears When i try to send multiple
requests to the server from the client. for the first requests, every thing
is fine
this is the code that causes the error:
for client.ReadClient(buffer) {
// Check for STX and ETX
posSTX := bytes.IndexByte(buffer, 0x02)
if(posSTX==-1){
return
}
posETX := bytes.IndexByte(buffer, 0x03)
if(posETX==-1){
return
}
Log("posSTX ",posSTX)
Log("posETX ",posETX)
msg := string(buffer[posSTX+1:posETX-posSTX])
}
i try in this code to extract the char "0x02" and "0x03" that delimit the
received message.
but sometimes posSTX is bigger than posETX that's what causes the error
"posSTX+1:posETX-posSTX"
anyone has an idea why it's correct for the first requests and not for the
rest??? what can be the solution for this??
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.