The intention of Builder Pattern is to separate the construction of a complex object from its representation so that the same construction process can create different representations
Let's take an example in building UI elements based on different libraries such as React, Vue and Angular. We need a thing so-called director to group the creation of UI element consistent across various area of our codebase. The Direction would take a builder as the only parameter to build a complete UI element later. The attachment below demonstrate just that:
Next, we want to define an interface for our UI element which is the final result of different builders.
And finally, we finish the implementation with a set of different builders for our UI elements which are React, Vue and Angular builders
And there we goes, we have a complete implementation of Builder Pattern in Go.
P/s: The accompany code is included in this PR 😊
Happy coding 😎