I’m writing some code that needs functionality that is almost satisfied by the ReadBytes method in the bufio package. Specifically, that method reads from a Reader until it encounters a particular byte. I need something that reads till it encounters one out of couple of bytes (space, newline and tab mainly).
I looked at the source for the library and I know what to do if I have access to the internal buffer used by bufio structs. Is there any way I could “monkey patch” the package and add another method or two to it? Or another way to get the functionality I need?
Something along this approach (caution: untested code):
EDIT: I should have noted that this doesn’t help to access the original package internals (non exported entities). Thanks Abhay for pointing that out in your comment.