Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
os: more descriptive error for File.ReadAt with negative offset #19031
What version of Go are you using (
@ianlancetaylor Yes, you're right.
@minux I agree there's a fine line between what the language should check for, and what the application should check. I understand there are way too many cases to account for.
I think this is a case that can be improved, that's why I raised the issue. Feel free to close the issue if you think it's not worth doing it in go level.
If we check this in application level, it would look like this making sure a non negative offset is passed.
…tive offset. The existing implementation does not provide a useful error message if a negative offset is passed in File.ReadAt or File.WriteAt. This change is to return descriptive errors. An error of type *PathError is returned to keep it consistent with rest of the code. There is no need to add an exported error variable since it's used only in one file. Fixes golang#19031 Change-Id: Ib94cab0afae8c5fe4dd97ed2887018a09b9f4538 Reviewed-on: https://go-review.googlesource.com/39136 Reviewed-by: Brad Fitzpatrick <firstname.lastname@example.org> Run-TryBot: Brad Fitzpatrick <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org>