Read arbitrary amount of bytes into buffer Golang

后端 未结 1 1490
伪装坚强ぢ
伪装坚强ぢ 2021-01-23 03:10

I\'m trying to read a stream of info from a connection. I haven\'t written the server part of it, and don\'t have access to modifying the protocol (or else I would have made the

相关标签:
1条回答
  • 2021-01-23 03:22

    If you want to read the whole stream of the connection you could use:

       var b bytes.Buffer
       if _, err:= io.Copy(&b, conn); err != nil {
          return err
       }
    
       Handle(b.Bytes())
    
    0 讨论(0)
提交回复
热议问题