Repository: smallnest/rpcx (language: go)

Issue:
文件传输服务，SendFile 中有一段代码，可能导致接收文件时数据大小不一致， 
```
sendBuffer := make([]byte, FileTransferBufferSize)
loop:
	for {
		select {
		case <-ctx.Done():
		default:
			if tb != nil {
				tb.Wait(FileTransferBufferSize)
			}
			n, err := file.Read(sendBuffer)
			if err != nil {
				if err == io.EOF {
					return nil
				} else {
					return err
				}
			}
			if n == 0 {
				break loop
			}
			_, err = conn.Write(sendBuffer)
			if err != nil {
				if err == io.EOF {
					return nil
				} else {
					return err
				}
			}
		}
	}
```

这段代码有个小BUG，应该是 
`_,err=conn.Write(sendBuffer[:n])`
否则对方接收数据时可能会有无效的内容


Discussion / hints:

Fix patch:
diff --git a/client/xclient.go b/client/xclient.go
index 68ac2655..b73d1853 100644
--- a/client/xclient.go
+++ b/client/xclient.go
@@ -1197,7 +1197,7 @@ loop:
 			if n == 0 {
 				break loop
 			}
-			_, err = conn.Write(sendBuffer)
+			_, err = conn.Write(sendBuffer[:n])
 			if err != nil {
 				if err == io.EOF {
 					return nil


Test patch: