You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type A struct{
PushedAt float32 `json:"pushed_at"`
}
func main() {
unixT := float32(1.5229495e+09)
a := A{
PushedAt: unixT,
}
b, _ := json.Marshal(a)
var c A
json.Unmarshal([]byte(b), &c)
fmt.Printf("%+v\n", a)
fmt.Printf("%+v\n", c)
fmt.Printf("%d\n", int64(a.PushedAt))
}
You can see there is a diff when converting a.PushedAt into int64.
When I use this number with time.Unix(sec int64, nsec int64), this makes severe difference of the time.
If we use float64 then we can get right answer.
How about using float64 instead??
Any pointers would much be appreciated.
Regards,
The text was updated successfully, but these errors were encountered:
I consider this is not a bug, it's UX thing.
When I run simple golang:
then I got the output:
You can see there is a diff when converting
a.PushedAt
intoint64
.When I use this number with
time.Unix(sec int64, nsec int64)
, this makes severe difference of the time.If we use
float64
then we can get right answer.How about using
float64
instead??Any pointers would much be appreciated.
Regards,
The text was updated successfully, but these errors were encountered: