The Options Pattern in Golang!? ~ Service Configuration

Author: samvcodes
Published At: 2023-12-01T00:00:00
Length: 03:27

Summary

Description

MY DISCORD!: https://discord.gg/TsbMDmejF5

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!

Twitter: https://twitter.com/samvcodes

Github: https://github.com/samverrall

Translated At: 2025-08-24T08:38:53Z

Request translate (One translation is about 5 minutes)

Version 3 (stable)

Optimized for a single speaker. Suitable for knowledge sharing or teaching videos.

Recommended Videos