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: support writing and reading integers from Buffer #5262

Closed
eaigner opened this issue Apr 10, 2013 · 2 comments
Closed

bytes: support writing and reading integers from Buffer #5262

eaigner opened this issue Apr 10, 2013 · 2 comments

Comments

@eaigner
Copy link
Contributor

eaigner commented Apr 10, 2013

When using bytes.Buffer to construct network protocol buffers (not to be confused with
google protobuf), it would be useful to have functions for writing and reading integer
values, like

    - ReadInt/64
    - WriteInt/64

thus avoiding the bitshift boilerplate

    var i int64 = 0x1234567890abcdef
    var b = []byte{
        byte(i >> 56 & 0xFF),
        byte(i >> 48 & 0xFF),
        byte(i >> 40 & 0xFF),
        byte(i >> 32 & 0xFF),
        byte(i >> 24 & 0xFF),
        byte(i >> 16 & 0xFF),
        byte(i >> 8 & 0xFF),
        byte(i & 0xFF),
    }
@eaigner
Copy link
Contributor Author

eaigner commented Apr 10, 2013

Comment 1:

Just discovered that binary.Write of "encoding/binary" does just that with arbitrary
types. Sorry.

@bradfitz
Copy link
Contributor

Comment 2:

Status changed to Retracted.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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