Not a Name
Not a Name

Reputation: 1003

How to read at least N bytes in Go

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?

Upvotes: 0

Views: 1019

Answers (1)

Krzysztof Kowalczyk
Krzysztof Kowalczyk

Reputation: 3563

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

Upvotes: 3

Related Questions