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 Updated 9 repo stars

File contents

muratmirgun/gophers commit 06ec2c67c3

Frequently asked questions

npx get-skill add muratmirgun/go-functional-options