Reference: https://www.sohamkamani.com/golang/options-pattern/
Is it tied directly to a Go feature, or a design pattern based on the basics?
It’s a design pattern based on the basics features:
- First class function
- Variadic function:
func NewHouse(opts ...HouseOption)
What’s the user case that makes it necessary?
When we have a set of default values for a struct that we are generally happy with, and then variable number of these values might need to be different upon construction.