Skip to main content
2 events
when toggle format what by license comment
Jul 1, 2019 at 14:13 comment added Elias Van Ootegem Singletons are usually to be avoided. The thing to ask yourself is: am I making life harder on myself WRT unit testing.. with singletons, the answer more often than not is yes. There's also a chance that redis.Client becomes invalid (connection drops, you may need to create a new client - IDK if that's the case here, but some packages work like that). Wrapping everything in a sync.Once makes reconnecting a lot harder in cases like that. Also Redis embeds Client, both fields are exported, what happens if someone accidentally assigns nil?
Jun 26, 2019 at 8:48 history asked Mahmudul Haque CC BY-SA 4.0