Closed ironman0x7b2 closed 5 years ago
In the above code, why am I getting Unix start time when I do unmarshal?
In amino, as in protobuf with which we want to be compatible, there is no difference in encoding default values and empty/missing values. The default value for time is the unix start time.
Time is a bit tricky though: In protobuf the equivalent struct would actually be decoded as you expected (nil). See for instance this test: https://github.com/tendermint/go-amino/blob/dc14acf9ef15f85828bfbc561ed9dd9d2a284885/tests/proto3/proto3_compat_test.go#L166-L185
The difference in amino is that we directly deal with encoding/decoding the time.Time
struct. So what you get at the end (epoch time) is what what protobuf would give you if you go from google.protobuf.Timestamp
to time.Time
(by using https://godoc.org/github.com/golang/protobuf/ptypes#Timestamp). Does that make sense to you? Do you think amino should behave differently here?
How can I get nil for the field T when I do unmarshal?
Currently you can't AFAIR.
@Liamsi Thank you for your clarification
In the above code, why am I getting Unix start time when I do unmarshal? How can I get
nil
for the field T when I do unmarshal?