Skip to content

Instantly share code, notes, and snippets.

@raecoo
Created July 12, 2018 00:54
Show Gist options
  • Save raecoo/4eab26f01a5e4fd3f03837b2e7cc97d3 to your computer and use it in GitHub Desktop.
Save raecoo/4eab26f01a5e4fd3f03837b2e7cc97d3 to your computer and use it in GitHub Desktop.
Msgpack serialization the []byte data by Go-lang
b := []byte{'g', 'o', 'o', 'g', 'l', 'e'}
s := string(b)
var mp interface{}
packedMp, _ := msgpack.Marshal(s)
msgpack.Unmarshal(packedMp, &mp)
println(b, s, packedMp, mp.(string))
#-> [6/6]0xc42014bf22 google [7/64]0xc42015b758 google
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment