Skip to content

Why does gbytes.Buffer.Read return an error when the buffer is closed? #573

@davidhsingyuchen

Description

@davidhsingyuchen

I'm trying to pass session.Wait().Out to bufio.NewScanner to parse the stdout and use the result in subsequent commands, but I guess that Wait() closes the buffer (i.e., Out), hence the issue.

Currently I'm using Out.Contents() instead, but that requires some workaround, so I decide to ask here at the same time.

I'm aware that this behavior is documented, but I fail to figure out the rationale behind.

The documentation of gbytes.Buffer.Close only mentions:

Close signifies that the buffer will no longer be written to

, and it seems that reading from a closed buffer is legit, just like reading from a closed channel.

Please let me know if I'm missing anything, thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions