You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go version go1.3.1 darwin/amd64
The following snippet illustrates the problem I'm encountering:
http://play.golang.org/p/7qCY_H5pnN
Another example: http://play.golang.org/p/5Jt-wqnlNT
What happened?
If you try to marshal / unmarshal a sha1 hash ([]byte) cast to a string, you don't get
the same string out as you put in.
What should have happened instead?
Ideally, you should get the same string out as you put in. If that turns out to be
impossible for some reason, maybe make the Marshal function return an error for strings
it can't handle?
Additional
You guys probably don't need this, but I tried the following as a sanity check for
myself on what it means to cast from []byte to string in go:
http://play.golang.org/p/9n7GLU9R14
The text was updated successfully, but these errors were encountered:
This behaviour, while sometimes annoying, is working as intended and is documented on
tip: "String values encode as JSON strings coerced to valid UTF-8, replacing invalid
bytes with the Unicode replacement rune." To use random bytes as a JSON string, you
need to convert them to hex, for example, modifying your first test case as
http://play.golang.org/p/qrpMkJC8Mb .
by slunk@terpmail.umd.edu:
The text was updated successfully, but these errors were encountered: