2012-09-26 14:50



After you establish a connection and you want to read the bytes coming from the connection, how can you read all the bytes? From what I tried, I can read until it reaches a delimiter like a line break. But how is it possible to get everything including the line breaks? I'm trying to make a redis client in Go and the protocol separates results with , so in this case Buffer.ReadLine, or Buffer.ReadSlice didn't help.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • douliao2493 douliao2493 9年前

    To read all bytes from a Reader (like your TCP connection), you can use ioutil.ReadAll, which reads until an EOF is sent from the other side or an error occurs.

    Please note that there are already some redis clients for go.

    点赞 评论 复制链接分享