Design Patterns | Singleton
Creational pattern - Singleton
1 | package cards |
Here we define package cards, that encapsulates relationship between card number and and owner of a card. It’s concurency free function func New()
code, that creates object only if it’s not initialized before.
Below you can find the basic usage of this pattern:
1 | package main |
Sample output of program shows that there are no another instance was created.