Go Functional Options

Use when designing a Go constructor or factory with 3+ optional parameters, or an API expected to grow new options over time. Covers the canonical Option interface pattern with unexported apply method, With* constructors, default values, and the interface-vs-closure tradeoff. Apply proactively when reviewing a New* function that takes many settings, even if the user didn't ask about functional options. Does not cover general function design (see go-functions).

muratmirgun 06ec2c6 4 files · 11.0 KB Updated

File contents

muratmirgun/gophers/tree/main/skills/go-functional-options commit 06ec2c67c3

Frequently asked questions

npx skillmds@latest add muratmirgun/go-functional-options