0

How do you ensure you get at least n bytes when reading from a file in Go? The function seems to return the number of bytes you got, but I would rather just wait until more bytes are available. Is this possible without doing a bunch of manual plumbing?

1 Answer 1

3

Use io.ReadAtLeast() function: http://golang.org/pkg/io/#ReadAtLeast

Sign up to request clarification or add additional context in comments.

1 Comment

io.ReadFull is often more convenient. (It's just a wrapper around io.ReadAtLeast anyway.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.