package core import ( "testing" "time" "github.com/google/go-cmp/cmp" ) func TestEncoder(t *testing.T) { in := Test{ Num1: 1, Time1: time.Now().Truncate(time.Second), Str1: "test string", Num2: 2, Bin1: []byte{0x01, 0x02, 0x03}, Num3: 3, Str2: "こんにちは", Num4: 4, } data, err := Encode(in) if err != nil { t.Error(err) } out, err := Decode(data) if err != nil { t.Error(err) } if diff := cmp.Diff(in, out); diff != "" { t.Errorf("structs are different (-in +out):\n%s", diff) } }