Git Product home page Git Product logo

Comments (7)

ugorji avatar ugorji commented on August 27, 2024

Thanks.

No need to send a minimal test case. I see the error. I'd upload a fix pronto.

from go.

armon avatar armon commented on August 27, 2024

Thanks!

from go.

armon avatar armon commented on August 27, 2024

Sorry, quick question, will the conversion of []byte to string potentially cause problems if the data is not UTF8 format?

from go.

armon avatar armon commented on August 27, 2024

The latest commit does fix our issue though. Thanks for the quick turn around!

from go.

ugorji avatar ugorji commented on August 27, 2024

Please re-test and confirm fix.

No - it will not cause an issue.

This is in line with the old logic before (see kMap method). We special-case and fast-tracked some common map types, and I forgot to replicate that check in there.

The reason for doing this, is that the original msgpack encodes a string as raw []byte (there was no separate string or binary type). When decoding, we need to make a determination what to do when we see raw bytes. We use the following to make that determination:

  • If we see raw bytes as key in a map, then it must have been a string (because Go doesn't support slices as map keys). So we just convert it to a string (else you get the error you received that hashmap cannot have a slice as a key value because slices do not support equality).
  • In any other situation that we see raw bytes in the stream, we use the value of the Option RawToString
    to determine what to do (either keep as []byte or convert to string).

A string in Go is just an immutable string of bytes - it doesn't specify an encoding. There are libs to treat it as utf8, utf16, runes (utf-32), etc.

from go.

ugorji avatar ugorji commented on August 27, 2024

And thanks for reporting this quickly. Much appreciated. I pride myself on not overlooking things, and am happy you caught this one for me quickly before others ran across it, and wasted time checking if the problem was on their end.

from go.

armon avatar armon commented on August 27, 2024

Thanks for the response and the excellent library! Cheers.

from go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.