go-functional-options — community go-functional-options, golang-skills, community, ide skills

v1.0.0

About this Skill

Ideal for Go-based AI Agents requiring extensible APIs and clean caller experiences through functional options. The functional options pattern for Go constructors and public APIs. Use when designing APIs with optional configuration, especially with 3+ parameters.

cxuu cxuu
[0]
[0]
Updated: 3/12/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reviewed Landing Page Review Score: 9/11

Killer-Skills keeps this page indexable because it adds recommendation, limitations, and review signals beyond the upstream repository text.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution Quality floor passed for review Locale and body language aligned
Review Score
9/11
Quality Score
51
Canonical Locale
en
Detected Body Locale
en

Ideal for Go-based AI Agents requiring extensible APIs and clean caller experiences through functional options. The functional options pattern for Go constructors and public APIs. Use when designing APIs with optional configuration, especially with 3+ parameters.

Core Value

Empowers agents to create idiomatic, production-ready Go code using the functional options pattern, supporting extensible APIs and variadic option constructors, thus enhancing the caller experience with opaque Option types and internal structs.

Ideal Agent Persona

Ideal for Go-based AI Agents requiring extensible APIs and clean caller experiences through functional options.

Capabilities Granted for go-functional-options

Implementing extensible APIs with 3+ optional arguments
Configuring result objects using variadic option constructors
Enhancing caller experience through clean and concise API design

! Prerequisites & Limits

  • Requires Go programming language
  • Limited to use cases with 3+ optional arguments or extensible APIs

Source Boundary

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

After The Review

Decide The Next Action Before You Keep Reading Repository Material

Killer-Skills should not stop at opening repository instructions. It should help you decide whether to install this skill, when to cross-check against trusted collections, and when to move into workflow rollout.

Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is go-functional-options?

Ideal for Go-based AI Agents requiring extensible APIs and clean caller experiences through functional options. The functional options pattern for Go constructors and public APIs. Use when designing APIs with optional configuration, especially with 3+ parameters.

How do I install go-functional-options?

Run the command: npx killer-skills add cxuu/golang-skills/go-functional-options. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for go-functional-options?

Key use cases include: Implementing extensible APIs with 3+ optional arguments, Configuring result objects using variadic option constructors, Enhancing caller experience through clean and concise API design.

Which IDEs are compatible with go-functional-options?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for go-functional-options?

Requires Go programming language. Limited to use cases with 3+ optional arguments or extensible APIs.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add cxuu/golang-skills/go-functional-options. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use go-functional-options immediately in the current project.

Upstream Repository Material

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

Upstream Source

go-functional-options

Install go-functional-options, an AI agent skill for AI agent workflows and automation. Review the use cases, limitations, and setup path before rollout.

SKILL.md
Readonly
Upstream Repository Material
The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.
Supporting Evidence

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)

The Pattern

Core Components

  1. Unexported options struct - holds all configuration
  2. Exported Option interface - with unexported apply method
  3. Option types - implement the interface
  4. With* constructors - create options

Option Interface

go
1type Option interface { 2 apply(*options) 3}

The unexported apply method ensures only options from this package can be used.

Complete Implementation

Source: Uber Go Style Guide

go
1package db 2 3import "go.uber.org/zap" 4 5// options holds all configuration for opening a connection. 6type options struct { 7 cache bool 8 logger *zap.Logger 9} 10 11// Option configures how we open the connection. 12type Option interface { 13 apply(*options) 14} 15 16// cacheOption implements Option for cache setting (simple type alias). 17type cacheOption bool 18 19func (c cacheOption) apply(opts *options) { 20 opts.cache = bool(c) 21} 22 23// WithCache enables or disables caching. 24func WithCache(c bool) Option { 25 return cacheOption(c) 26} 27 28// loggerOption implements Option for logger setting (struct for pointers). 29type loggerOption struct { 30 Log *zap.Logger 31} 32 33func (l loggerOption) apply(opts *options) { 34 opts.logger = l.Log 35} 36 37// WithLogger sets the logger for the connection. 38func WithLogger(log *zap.Logger) Option { 39 return loggerOption{Log: log} 40} 41 42// Open creates a connection. 43func Open(addr string, opts ...Option) (*Connection, error) { 44 // Start with defaults 45 options := options{ 46 cache: defaultCache, 47 logger: zap.NewNop(), 48 } 49 50 // Apply all provided options 51 for _, o := range opts { 52 o.apply(&options) 53 } 54 55 // Use options.cache and options.logger... 56 return &Connection{}, nil 57}

Usage Examples

Source: Uber Go Style Guide

Without Functional Options (Bad)

go
1// Caller must always provide all parameters, even defaults 2db.Open(addr, db.DefaultCache, zap.NewNop()) 3db.Open(addr, db.DefaultCache, log) 4db.Open(addr, false /* cache */, zap.NewNop()) 5db.Open(addr, false /* cache */, log)

With Functional Options (Good)

go
1// Only provide options when needed 2db.Open(addr) 3db.Open(addr, db.WithLogger(log)) 4db.Open(addr, db.WithCache(false)) 5db.Open( 6 addr, 7 db.WithCache(false), 8 db.WithLogger(log), 9)

Comparison: Functional Options vs Config Struct

AspectFunctional OptionsConfig Struct
ExtensibilityAdd new With* functionsAdd new fields (may break)
DefaultsBuilt into constructorZero values or separate defaults
Caller experienceOnly specify what differsMust construct entire struct
TestabilityOptions are comparableStruct comparison
ComplexityMore boilerplateSimpler setup

Prefer Config Struct when: Fewer than 3 options, options rarely change, all options usually specified together, or internal APIs only.

Why Not Closures?

Source: Uber Go Style Guide

An alternative implementation uses closures:

go
1// Closure approach (not recommended) 2type Option func(*options) 3 4func WithCache(c bool) Option { 5 return func(o *options) { o.cache = c } 6}

The interface approach is preferred because:

  1. Testability - Options can be compared in tests and mocks
  2. Debuggability - Options can implement fmt.Stringer
  3. Flexibility - Options can implement additional interfaces
  4. Visibility - Option types are visible in documentation

Quick Reference

go
1// 1. Unexported options struct with defaults 2type options struct { 3 field1 Type1 4 field2 Type2 5} 6 7// 2. Exported Option interface, unexported method 8type Option interface { 9 apply(*options) 10} 11 12// 3. Option type + apply + With* constructor 13type field1Option Type1 14 15func (o field1Option) apply(opts *options) { opts.field1 = Type1(o) } 16func WithField1(v Type1) Option { return field1Option(v) } 17 18// 4. Constructor applies options over defaults 19func New(required string, opts ...Option) (*Thing, error) { 20 o := options{field1: defaultField1, field2: defaultField2} 21 for _, opt := range opts { 22 opt.apply(&o) 23 } 24 // ... 25}

Checklist

  • options struct is unexported
  • Option interface has unexported apply method
  • Each option has a With* constructor
  • Defaults are set before applying options
  • Required parameters are separate from ...Option

See Also

Related Skills

Looking for an alternative to go-functional-options or another community skill for your workflow? Explore these related open-source skills.

View All

openclaw-release-maintainer

Logo of openclaw
openclaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

333.8k
0
AI

widget-generator

Logo of f
f

Generate customizable widget plugins for the prompts.chat feed system

149.6k
0
AI

flags

Logo of vercel
vercel

The React Framework

138.4k
0
Browser

pr-review

Logo of pytorch
pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration

98.6k
0
Developer