go-options-gen

Generate type-safe functional options for Go components with options-gen.

21|1|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/metalagman/agent-skills --skill go-options-gen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-options-gen
Source: https://github.com/metalagman/agent-skills/tree/main/go-options-gen
Command: npx skills add https://github.com/metalagman/agent-skills --skill go-options-gen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Designing configurable Go components often leads to boilerplate and unsafe code when exposing configuration. options-gen enables generating type-safe, unexported option setters and a clean exported API, reducing boilerplate and improving encapsulation.

Core Features & Use Cases

  • Generate unexported option fields with generated setters for validated configuration.
  • Enforce validation tags and required fields through a standard constructor pattern.
  • Support multiple options in one package and flexible defaults to tailor constructors.

Quick Start

Install the options-gen tool and run go generate to produce the generated option code.

Frequently Asked Questions about go-options-gen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate type-safe functional options for Go components?

Generate type-safe functional options in Go using the options-gen library to create unexported option fields with generated setter methods. This reduces boilerplate and enforces validated configuration through code generation.

How do I enforce mandatory fields and defaults in a Go constructor?

Enforce mandatory fields and defaults in a Go constructor by applying validation tags and required field definitions during functional options generation. The standard constructor pattern validates these settings before component initialization.

What is the best way to encapsulate configuration with unexported fields in Go?

Encapsulate configuration with unexported fields in Go by generating type-safe option setters that expose a clean API. This approach hides internal state while providing validated configuration methods for component initialization.

Can I generate multiple functional options in one Go package?

Yes, you can generate multiple functional options within a single Go package. The options generation process supports defining multiple configurable components alongside flexible defaults to tailor constructors for each specific component.

How do I integrate generated option setters into existing Go packages?

Integrate generated option setters into existing Go packages by running go generate to produce the option code, then applying the standard constructor pattern. This enforces validation tags and required fields during component initialization.