The professional term for Option mode is: Functional Options Pattern (Functional Options Pattern)
Option mode provides golang developers with the ability to set the parameters of a function as optional. That is to say, we can select some of the parameters and pass in the parameters in any order.
For example, for special scenarios that require different parameters, C++ can directly use overloading to write any function with the same name, and use the same function name when calling any scenario; but in the same case, in golang we must Different scenarios use different functions, and the parameter passing method may be different when written by different people, which will lead to poor code readability and poor maintainability.
Advantages and disadvantages of Option mode
advantage
Support for passing multiple parameters, and maintain compatibility when the number and type of parameters change
Pass parameters in any order
Support default value
Easy to expand
Disadvantage
Add many functions and increase the cost
When the parameters are not too complicated, try to use them sparingly