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

I can't attach the snappy.Reader to a string.. #34

Open
paidir opened this issue Aug 28, 2016 · 1 comment
Open

I can't attach the snappy.Reader to a string.. #34

paidir opened this issue Aug 28, 2016 · 1 comment

Comments

@paidir
Copy link

paidir commented Aug 28, 2016

code:

    stringReader := strings.NewReader(pbMsg.GetBody().GetReqData().GetContent())
    snappyReader := snappy.NewReader(stringReader)
    rNum, _ := snappyReader.Read(conBytes)

line:pbMsg.GetBody().GetReqData().GetContent() return a string . when using the stringReader as the paramater , the rNum is 0, why? 3q very much

@nigeltao
Copy link
Contributor

nigeltao commented Aug 29, 2016

The first step is: don't ignore the error that snappyReader.Read is returning.

After that, I'm only guessing, but there is a difference between the block Snappy format, and the streaming Snappy format. The streaming format is the block format plus a framing header. The snappy.Reader is for the streaming format, but most people use the block format. Try this instead:

decoded, err := snappy.Decode(nil, []byte(pbMsg.GetBody().GetReqData().GetContent()))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants