Last active
May 13, 2016 13:45
-
-
Save nicholasknight/62fda58c3dc3c27c60209a22a88b44c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/url" | |
"gopkg.in/vmihailenco/msgpack.v2" | |
) | |
func main() { | |
u, err := url.Parse("https://github.com/vmihailenco/msgpack") | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("Original struct: %+v\n", *u) | |
b, err := msgpack.Marshal(u) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("msgpack bytes: %+v\n", string(b)) | |
var v url.URL | |
err = msgpack.Unmarshal(b, &v) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("Deserialized struct: %+v\n", v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment