I don't fully understand the problem, but if you need a quick and dirty way
to ensure a function is called exactly once, you can always use a global
variable, have the function checks the variable when the function is
called. If the function is called the first time, it will set the variable.
If the function has been called more than once, it should panic and returns
On Friday, August 11, 2017 at 3:02:47 AM UTC+7, dc0d wrote:
> Is there a tool/linter to check if a private package function gets called
> exactly once *in the code*? (I'm not looking for a runtime solution like
> *sync.Once* but a code analysis tool/linter).
> Purpose: A guideline on commenting code by Martin Fowler states that
> before writing a comment, see if it is possible to put that part inside a
> meaningful function. I've followed that guideline for sometime and it helps
> to have a cleaner code base. But those explanatory functions should get
> called only from where that they are meant to make it more clear.
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.