<p>I am using sync.once to implement singleton in my microservice. But I am not sure if this will ensure a single instance for all the replicas.
How to create a Singleton object for distributed microservices in golang?</p>

Vaibhav
<p>It cannot ensure a single instance between multiple processes running in different environments. <code>sync</code> is used to synchronise go routines, which are running against the main routine process.</p>
<p>To add locking that would work between multiple processes and multiple microservices, you need a single third-party instance, that would control it. It can be a queue message / cache broker (e.g. <a href="https://www.rabbitmq.com/" rel="nofollow noreferrer">RabbitMQ</a>, <a href="https://redis.io/" rel="nofollow noreferrer">Redis</a>) or database (e.g. <a href="https://www.postgresql.org/docs/13/explicit-locking.html#ADVISORY-LOCKS" rel="nofollow noreferrer">PostgreSQL advisory locks</a>).</p>
