On Thu, Jun 30, 2016, at 01:10 PM, awickert wrote:
>
>
> Am Donnerstag, 30. Juni 2016 08:29:32 UTC+2 schrieb krma...@gmail.com:
>> I want a single instance of a client handle to be initialized.
>>
>> Is it ok to declare the instance as
>>
>> var client MetricsClient
>>
>> and then initialize it using sync.Once().
>>
>> Is it required for some reason that the client be a pointer  or are
>> there are other issues with it. My requirement is to be able to
>> initialize that handle just once
>
> You can implement a singelton similar to Java. A paper [0] has already
> solved the problem in 2010. Simply take a look at section 3.1.
>
>
> [] http://www.doc.ic.ac.uk/~ncameron/papers/schmager_plateau10.pdf
 
The solution presented in the paper is racy and it would be quite
possible to get two copies of the registry. Better to use sync.Once to
initialise it.
 
-- Ian
 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to