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: buffer.readSlice is not exported #15154

Closed
Tasssadar opened this issue Apr 6, 2016 · 3 comments
Closed

bytes: buffer.readSlice is not exported #15154

Tasssadar opened this issue Apr 6, 2016 · 3 comments

Comments

@Tasssadar
Copy link
Contributor

Currently, readSlice method in bytes.Buffer is private, which means there is no easy way to read the buffer by delimiter without needlessly allocating another slice.

Since it is already there, and bufio package has the same method exported, I propose making this method exported in the bytes package as well (with proper warnings about its usage in the comments, the same way bufio does it).

I can submit a patch, but since I'm not sure whether these kind of changes are acceptable (it is non-breaking change, right?), I'd rather ask first.

@bradfitz
Copy link
Contributor

bradfitz commented Apr 6, 2016

Can't you already do this by calling Buffer.Peek + searching Buffer.Bytes in a loop with an increasingly large peek value?

@bradfitz bradfitz added this to the Unplanned milestone Apr 6, 2016
@Tasssadar
Copy link
Contributor Author

Yes, you can, or just implement readSlice yourself in like 5 lines. It is just a matter of convenience and bufio already has it (in fact, it took me a while to figure out why do I remember that I could use ReadSlice - I've used it on bufio.Reader previously), so I thought I'd mention it and/or send a patch.

@bradfitz
Copy link
Contributor

bradfitz commented Apr 6, 2016

Sorry, I don't think we'll do this. We try not to expand the API unless it's really valuable (needed by many people and/or solves a problem not otherwise solvable). I don't think this falls into either of those buckets.

Related: https://golang.org/doc/faq#x_in_std

@bradfitz bradfitz closed this as completed Apr 6, 2016
@golang golang locked and limited conversation to collaborators Apr 6, 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