Flyweight Pattern:
The Flyweight design pattern is a structural design pattern that provides a way to use objects in large numbers when a simple repeated representation would use an unacceptable amount of memory. It achieves this by sharing (reusing) object properties to save space. It's called Flyweight because it models the way a flyweight boxer minimizes their weight to stay in their weight class, in the same way that this pattern minimizes memory usage. Imagine a forest with millions of trees. Each tree has detailed data like age, height, color, location, etc. If we created unique data for every single tree, it would require a huge amount of memory. Instead, we can classify trees into a few types, and for each type, we can create a single object (a flyweight), and then all of the same typed trees can reference the flyweight for common data. In this case, we only need to store unique data (like location) for each tree, therefore significantly reducing memory usage. Implementation in Go: