AI SummaryTeaches the functional options pattern for designing flexible Go APIs with optional configuration, helping developers build clean, extensible constructors that scale as requirements grow.
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to install the "go-functional-options" skill in my project. Please run this command in my terminal: # Install skill into the correct directory mkdir -p .claude/skills/go-functional-options && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/go-functional-options/SKILL.md "https://raw.githubusercontent.com/cxuu/golang-skills/main/skills/go-functional-options/SKILL.md" Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.
Description
The functional options pattern for Go constructors and public APIs. Use when designing APIs with optional configuration, especially with 3+ parameters.
Usage Examples
> Source: Uber Go Style Guide
Functional Options Pattern
> Source: Uber Go Style Guide Functional options is a pattern where you declare an opaque Option type that records information in an internal struct. The constructor accepts a variadic number of these options and applies them to configure the result.
When to Use
Use functional options when: • 3+ optional arguments on constructors or public APIs • Extensible APIs that may gain new options over time • Clean caller experience is important (no need to pass defaults)
Core Components
• Unexported options struct - holds all configuration • Exported Option interface - with unexported apply method • Option types - implement the interface • With* constructors - create options
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster