jonboulle / clockwork

a fake clock for golang
Apache License 2.0
656 stars 58 forks source link

Convert FakeClock to a struct. #71

Closed DPJacques closed 1 year ago

DPJacques commented 1 year ago

This change ensures future modifications to FakeClock will not break users.

However, this change does break current users who use FakeClock as an argument, return value, or embed it in a struct or interface.

With limtied exception, build errors can be fixed by running:

$ grep -rl 'clockwork.FakeClock' /path/to/code_base | \
    xargs sed -i 's/clockwork.FakeClock/*clockwork.FakeClock/g'

Other rare build errors and their fixes are:

The alternative approach would have been to use type aliases. However, this does not provide a benefit over direct replacement, because the migration is more complicated, harder to execute, needs to be done to the same code points, and results in runtime failures when type converting (whereas this approach only fails at compile-time).