Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytes: Reader should use new io.SeekStart, io.SeekCurrent, and io.SeekEnd constants #15269

Closed
ericlagergren opened this issue Apr 13, 2016 · 5 comments
Milestone

Comments

@ericlagergren
Copy link
Contributor

In acefcb7 three new constants were added for seeking positions in a stream of bytes.

bytes.Reader, strings.Reader, and io.SectionReader currently do not use these constants and instead use 0, 1, and 2.

Since packages bytes and strings (and by default io) all import io, it'd make sense to use those constants internally for their Readers' Seek methods.

IMO it doesn't make sense to import io into any other packages for the sake of using named constants.

It's a rather trivial issue but it would clarify the source code which iirc was one of the reasons for having defined constants.

@bradfitz bradfitz self-assigned this Apr 13, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 13, 2016
@bradfitz
Copy link
Contributor

Agreed. Will do.

@ericlagergren
Copy link
Contributor Author

@bradfitz it was also mentioned in that CL that the comments should probably be reworded to say stream instead of file. (I think Rob said it.)

Unsure if that requires its own issue since it's so trivial.

s/stream/Reader/

@bradfitz
Copy link
Contributor

You can't seek on a stream. Bikeshed that elsewhere.

@gopherbot
Copy link

CL https://golang.org/cl/21962 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/22097 mentions this issue.

gopherbot pushed a commit that referenced this issue May 6, 2016
CL/19862 (f79b50b) recently introduced the constants
SeekStart, SeekCurrent, and SeekEnd to the io package. We should use these constants
consistently throughout the code base.

Updates #15269

Change-Id: If7fcaca7676e4a51f588528f5ced28220d9639a2
Reviewed-on: https://go-review.googlesource.com/22097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Apr 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants