Skip to content

Commit e6cf5be

Browse files
committed
refactor: inline condition check
1 parent 0657788 commit e6cf5be

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

mcp/transport.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,12 @@ func (t *ioConn) Read(ctx context.Context) (jsonrpc.Message, error) {
423423

424424
// Read the next byte to check if there is trailing data.
425425
var tr [1]byte
426-
n, err := in.Buffered().Read(tr[:])
427-
if n > 0 {
426+
if n, err := in.Buffered().Read(tr[:]); n > 0 {
428427
// If read byte is not a newline, it is an error.
429428
if tr[0] != '\n' {
430429
return nil, fmt.Errorf("invalid trailing data at the end of stream")
431430
}
432-
}
433-
// Return error except for EOF
434-
if err != nil && err != io.EOF {
431+
} else if err != nil && err != io.EOF {
435432
return nil, err
436433
}
437434

0 commit comments

Comments
 (0)