The Options Pattern in Golang!? ~ Service Configuration

preview_player
Показать описание
In this video, I discuss a simple concept to set optional fields with Golang structs/library configuration, this is commonly known as the Options pattern.

I typically use this pattern for setting optional fields on things like HTTP servers (as shown in this video), and any library with defaults that can be overwritten etc

I personally prefer this approach rather than opting for a Config struct or just plain old arguments, and getting for `nil` values for example.

Let me know what you think of this pattern, and if you've used it!

Рекомендации по теме
Комментарии
Автор

I love implementing this pattern, it feels much cleaner than a bloated config struct. Great overview!

matthewrawlings
visit shbcf.ru