Created
January 19, 2015 13:56
-
-
Save fredr/be78ebe33b894ef4c833 to your computer and use it in GitHub Desktop.
This file contains 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" | |
"log" | |
"time" | |
"github.com/vmihailenco/msgpack" | |
) | |
type EmbTime struct { | |
time.Time | |
} | |
type Thing struct { | |
T1 time.Time | |
T2 EmbTime | |
} | |
func main() { | |
var i interface{} | |
t := time.Now() | |
i = Thing{ | |
T1: t, | |
T2: EmbTime{t}, | |
} | |
fmt.Printf("i: %#v\n", i) | |
encoded, err := msgpack.Marshal(i) | |
if err != nil { | |
log.Fatal(err) | |
return | |
} | |
fmt.Println(encoded) | |
var out interface{} | |
if err = msgpack.Unmarshal(encoded, &out); err != nil { | |
log.Fatal(err) | |
return | |
} | |
fmt.Printf("out: %#v\n", out) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment