Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tranvictor/4cd3470c5572e0123d123540a9d8069d to your computer and use it in GitHub Desktop.
Save tranvictor/4cd3470c5572e0123d123540a9d8069d to your computer and use it in GitHub Desktop.
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