Created
March 7, 2019 06:21
-
-
Save tranvictor/4cd3470c5572e0123d123540a9d8069d 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
func (tl *TradeLog) UnmarshalJSON(b []byte) error { | |
type AliasTradeLog TradeLog | |
type mask struct { | |
Timestamp int64 `json:"timestamp"` | |
*AliasTradeLog | |
} | |
m := mask{ | |
Timestamp: 0, | |
AliasTradeLog: (*AliasTradeLog)(tl), | |
} | |
err := json.Unmarshal(b, &m) | |
if err != nil { | |
return err | |
} | |
tl.Timestamp = time.Unix(0, m.Timestamp*1000000) | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment