Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
Let's code up a simplistic example about an online store that has custom register to it. Once the item available in stock, we will email every single customer in the system about the change. Firstly, we would need a subject interface
Next up, the concrete implementation of the subject so-called Product
Last but no least is the subscriber interface and its implementation
There we have it - the implementation of Observer Pattern in Go. This pattern is most useful when we are dealing with any sort of notification system such as e-commerce, stock exchange, bidding, et cetera
P/s: The accompany code is included in this PR 😊
Happy coding 😎