Hey,

I have a TCP client which reads data from server. Each message is ; 
delimited. I wonder what's the correct way to use bufio.Reader, as I'm 
getting empty messages.

reader := bufio.NewReader(conn)
for {
    msg, err := reader.ReadBytes(59) // ; as delimiter
    if err == nil {
        fmt.Printf("%v\n", string(msg))
    }
}

So sometimes I will get a msg that's only ";". I wonder if bufio.Reader can 
be re-used as I do it on my for loop? Or are there any handy packages that 
I could use to parse the ";" delimiter?

I tried to write my own parser, but somehow bufio.Reader is like 3-4x 
faster even I thought I had an optimized code.

Thanks
- TH

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e4c474c8-87b0-400d-9576-c26ad54f585en%40googlegroups.com.

Reply via email to