Skip to content

Commit

Permalink
refactor: add io.EOF check
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthPestilane committed Jan 30, 2024
1 parent 7ec026f commit af8cc9e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func (d *DefaultPacker) Unpack(reader io.Reader) (*Message, error) {
id := d.bytesOrder().Uint32(headerBuffer[4:8])
data := make([]byte, dataSize)
if _, err := io.ReadFull(reader, data); err != nil {
if err == io.EOF {
return nil, err
}
return nil, fmt.Errorf("read data err: %s", err)
}
return NewMessage(int(id), data), nil
Expand Down

0 comments on commit af8cc9e

Please sign in to comment.