Reading a Specific Amount of Data from a File

Let’s learn how to read a specific amount of data from a file.

Reading in chunks

This lesson teaches us how to read a specific amount of data from a file. The presented utility can come in handy when we want to see a small part of a file. The numeric value that is given as a command-line argument specifies the size of the buffer that is going to be used for reading.

Coding example

The most important code of readSize.go is the implementation of the readSize() function:

Get hands-on with 1200+ tech skills courses.