Skip to content

Reader.String()/Bytes()/Int() should return an error if Peek() fails rather than destroy the connection state #15

@mikn

Description

@mikn

Reader functions String() and Bytes() and thus Result.Scan(Scanner) currently only supports returning values when tokenLen < buf.Size() the problem is obviously that this is a bit obscure. Should this be documented as an "expected behaviour" and steer people to use Result.Scan(io.Writer) instead (and throw appropriate error messages) or should we implement support for size up to Redis max size?
The first way would encourage "good behaviour", as in that it makes people think about how much memory they're allocating (and thus copying) and steer them to using various buffers (such as strings.Builder{} or bytes.Buffer{}) rather than "blindly" use the primitive types. The second would allow people to shoot themselves in the foot if they want to, and many people may want that. 🤔

I'm currently leaning towards throwing errors and encourage good behaviour as I'm a bit of a Good Samaritan in that sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions