I'm using time.Duration
to store data in a struct as follows:
type ApiAccessToken struct {
...
ExpiredIn *time.Duration `bson:"expired_in,omitempty" json:"expired_in,omitempty"`
...
}
and I set it using a constant like this:
...
const ApiAccessTokenDefaultExpiresIn = 7 * 24 * time.Hour
...
d := ApiAccessTokenDefaultExpiresIn
data := &ApiAccessToken{
...
ExpiredIn: &d
...
}
...
then I use mgo
to insert the data to database.
I did checking after creating the data
instance and before inserting the data and the value of ExpiredIn
was 604'800'000'000'000 but in MongoDB it became 604'800'000 (or NumberLong(604800000)
).
Any idea why? Thank you!