Go Tidbit: How Much Was Read From io.Reader?

from blog Blog on hjr265.me, | ↗ original
You have an io.Reader, and you are about to pass it to some utility that will read from it. But the utility won’t tell you how much it has read from the io.Reader. How do you figure out how many bytes of data were in the io.Reader? Like this snippet of Go+AWS code: 1 2 3 4 5 6 7 8 9 func uploadToS3(r io.Reader) (int64, error) { _, err := s3manager.