Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conn.WriteTo(w io.Writer) 返回值问题 #343

Closed
JemmyH opened this issue Mar 13, 2022 · 2 comments
Closed

conn.WriteTo(w io.Writer) 返回值问题 #343

JemmyH opened this issue Mar 13, 2022 · 2 comments
Assignees
Labels
bug Something isn't working pending development Requested PR owner to improve code and waiting for the result

Comments

@JemmyH
Copy link
Contributor

JemmyH commented Mar 13, 2022

Describe the bug
这里的返回值应该是 n + int64(m) ?
image

To Reproduce
Steps to reproduce the behavior:
None

Expected behavior
应该返回 n + int64(m)

func (c *conn) WriteTo(w io.Writer) (n int64, err error) {
	if c.inboundBuffer.IsEmpty() {
		var m int
		m, err = w.Write(c.buffer)
		c.buffer = c.buffer[m:]
		return int64(m), err
	}
	n, err = c.inboundBuffer.WriteTo(w)
	if err != nil {
		return
	}
	var m int
	m, err = w.Write(c.buffer)
	c.buffer = c.buffer[m:]
	return n + int64(m), err
}

Screenshots
If applicable, add screenshots to help explain your problem.

System Info (please fill out the following information):

  • OS (e.g. Ubuntu 18.04): macOS 12.2.1
  • Go version (e.g. Go 1.13): go1.17.5 darwin/amd64
  • gnet version (e.g. v1.0.0): v2

Additional context
Add any other context about the problem here.

@JemmyH JemmyH added the bug Something isn't working label Mar 13, 2022
@panjf2000
Copy link
Owner

这里的确有问题,我晚点改一下。

@panjf2000
Copy link
Owner

或者你有时间的话也可以提一个 PR。

@panjf2000 panjf2000 added the pending development Requested PR owner to improve code and waiting for the result label Mar 13, 2022
0-haha pushed a commit to 0-haha/gnet that referenced this issue Jan 25, 2023
…2000#344)

Fixes panjf2000#343 

Co-authored-by: hujiaming.0927 <hujiaming.0927@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending development Requested PR owner to improve code and waiting for the result
Projects
None yet
Development

No branches or pull requests

2 participants