Info about buffo ReadBytes function

ReadBytes function of buffo says It returns EOF if it encounters any issue while reading file.

Is this true?

ReadBytes reads until the first occurrence of delim in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadBytes returns err != nil if and only if the returned data does not end in delim. For simple uses, a Scanner may be more convenient.

My file is of 1GB and I am facing issue after reading 168 lines. Is there any other package which returns actual error or reads 1GB file?

Thanks,
Akhil

Hi @akhilravuri,

Note the word “often” in the description.

If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF).

So io.EOF is a special case. It is one particular error that can be returned, among other errors. In fact, io.EOF is not even a real error but rather just an indicator that the end of the input has been reached.

If you get an error before the whole file has been read, the error you get should be different from io.EOF. In this case, the actual error message you get should provide a hint about what goes wrong.

If this does not help, please share the actual error message you get, and if possible, also a minimal version of the code that is able to replicate the error.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.