Skip to content

Instantly share code, notes, and snippets.

@FabioRodrigues
Created August 17, 2023 11:02
Show Gist options
  • Save FabioRodrigues/aff3e7f598aa3264cd9b1d7b6dc04514 to your computer and use it in GitHub Desktop.
Save FabioRodrigues/aff3e7f598aa3264cd9b1d7b6dc04514 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"github.com/vmihailenco/msgpack"
)
func main() {
// Create a sample map[string]interface{}
personMap := map[string]interface{}{
"Name": "Jane Smith",
"Age": 25,
"Address": "456 Elm St, Town",
}
// Serialize the map to MessagePack format
packedData, err := msgpack.Marshal(personMap)
if err != nil {
log.Fatal(err)
}
fmt.Println("Serialized data:", packedData)
// Deserialize the MessagePack data back to a map
var unpackedMap map[string]interface{}
err = msgpack.Unmarshal(packedData, &unpackedMap)
if err != nil {
log.Fatal(err)
}
fmt.Println("Unpacked Map:", unpackedMap)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment