Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimise bugs by removing top level implementation? #4

Open
dmjones opened this issue Feb 27, 2018 · 0 comments
Open

Minimise bugs by removing top level implementation? #4

dmjones opened this issue Feb 27, 2018 · 0 comments

Comments

@dmjones
Copy link

dmjones commented Feb 27, 2018

Great package, but I'm confused by the presence of a top level set of functions, e.g. clock.Now().

This makes it easier to do silly bugs like:

type someStruct {
  clock clock.Clock
}

func (s someStruct) someTimeCriticalFunc() {
  currentTime := clock.Now() // should be s.clock.Now()
}

Ignoring backwards compatibility for a second, what is the benefit of having the clock.Now() function? Anyone who specifically wants the real time can just call clock.New().Now(). Or even just call time.Now(), since they obviously know they need the correct time at that point in their code.

I thought the whole point of this library would be to force users to access all time information through an interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant