use int64 type to prevent year 2038 problem on 32bit machines #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
motivation
I'm using this duration library in a project and tinkered around with long-running timers/durations.
I see an issue with potential wrong calculations when using seconds in combination with time.Duration builtin object.
https://en.wikipedia.org/wiki/Year_2038_problem
That said, on all 64bit machines, that should not be a problem, since int is compiled as 64bit.
What's the change
This PR introduces a breaking change, by using the type int64 instead of int in the Duration struct.
This is aligned with being compatible with Golang standard runtime using int64 as well.
Also, I took the freedom to add documentation per each field, which eases further the usage, as these single letters are not much self-explanatory.