cmpopts: add EquateApproxDuration
- Dominant language
- Go
- Stars
- 4.7k
- Forks
- 243
- PR merge metrics
- No merged PRs in 30d
Description
#155 added the ability to provide a margin for comparing time.Time, but some projects have needed to define their own custom comparers to handle margins for duration comparisons. It seems like it occurs enough to potentially be nice to add a new `EquateApproxDuration` opt.
Some examples:
- [crossplane](https://github.com/crossplane/crossplane/blob/f018aac0689c4dea80096490ee5d712b6c123566/internal/controller/ops/cronoperation/reconciler_test.go#L41-L53)
- [vegeta](https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/metrics_test.go#L88-L113)
- [gotest.tools](https://github.com/gotestyourself/gotest.tools/blob/0b81523ff268a1f1b0baf4a5da67e42fbb86880b/assert/opt/opt.go#L14-L29)
Contributor guide
Assessment
This issue has not been assessed yet.