원클릭으로
go-options-gen
Expert in generating functional options for Go structs using the options-gen library.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Expert in generating functional options for Go structs using the options-gen library.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Use this skill to build, run, deploy, evaluate, and troubleshoot Go agents with Google's Agent Development Kit (`google.golang.org/adk`), including `llmagent` config, toolsets/skills, callbacks/plugins, sessions/state/memory, workflows, MCP/A2A, and current runtime/deployment patterns.
Use this skill to manage work in Beads (`bd`) 1.0+, a Dolt-backed issue tracker for AI agents, including issue lifecycle, agent setup, recovery, workflows, and multi-repo coordination.
Use this skill to initialize, configure, and run omnidist release workflows for Go projects (`init`, `ci`, `build`, `stage`, `verify`, `publish`) including npm and uv publishing setup.
Maintain Go repositories with high-quality standards, adhering to CI/CD, linting, and agent-friendly best practices.
Use this skill to install and use the upstream powerman/golangci-lint-strict config for an exact golangci-lint version by fetching the versioned config file unchanged.
Use this skill to build, refactor, or review Go applications using the Uber Fx dependency injection framework. It ensures idiomatic use of Fx for lifecycle management, module-based architecture, and boilerplate reduction.
SOC 직업 분류 기준
| name | go-options-gen |
| description | Expert in generating functional options for Go structs using the options-gen library. |
| metadata | {"short-description":"Functional options generation for Go."} |
You are an expert in using the options-gen library (https://github.com/kazhuravlev/options-gen) to create robust, type-safe functional options for Go components. You prioritize unexported option fields to maintain encapsulation while providing a clean, exported API for configuration.
options.go, and generated code MUST be in options_generated.go.MyService, the struct (e.g., MyServiceOptions) MUST be in myservice_options.go, and generated code MUST be in myservice_options_generated.go.go tool options-gen.go.mod using:
go get -tool github.com/kazhuravlev/options-gen/cmd/options-gen@latest
go-playground/validator syntax) for configuration fields.Validate() method within the component's constructor.opts within your component struct.Installation: Ensure the tool is tracked in your project:
go get -tool github.com/kazhuravlev/options-gen/cmd/options-gen@latest
Define Options (options.go):
Define your options struct with unexported fields. Use the //go:generate directive to specify the output filename and the target struct.
package mypackage
import "time"
//go:generate go tool options-gen -from-struct=Options -out-filename=options_generated.go
type Options struct {
timeout time.Duration `option:"mandatory" validate:"required"`
maxRetries int `default:"3" validate:"min=1"`
endpoints []string `option:"variadic=true"`
}
Generate: Run the generator:
go generate ./options.go
Integration:
Use the generated types in your component's constructor and store them in an opts field.
type Component struct {
opts Options
}
func New(setters ...OptionOptionsSetter) (*Component, error) {
opts := NewOptions(setters...)
if err := opts.Validate(); err != nil {
return nil, fmt.Errorf("invalid options: %w", err)
}
return &Component{opts: opts}, nil
}
option:"mandatory" for fields that have no safe default (e.g., API keys, target URLs). These become required arguments in NewOptions().default:"value" for sensible defaults. options-gen supports basic types and time.Duration.For complex types (like maps or nested structs), use -defaults-from=func in the generate directive and define a provider function:
//go:generate go tool options-gen -from-struct=Options -out-filename=options_generated.go -defaults-from=func
func defaultOptions() Options {
return Options{
headers: map[string]string{"User-Agent": "my-client"},
}
}
validate:"required" for any field that must not be zero-valued.validate:"oneof=tcp udp" for enum-like string fields.validate:"min=1" for counters or sizes.For slice fields, use option:"variadic=true" to generate a setter that accepts multiple arguments (e.g., WithEndpoints("a", "b")) instead of a single slice (e.g., WithEndpoints([]string{"a", "b"})).
By keeping fields unexported in options.go, you ensure that the only way to configure the component is through the generated With* setters, which can include validation logic.
When a package contains multiple components (e.g., Client and Server), use prefixes to avoid name collisions in generated types and functions.
<prefix>_options.go and <prefix>_options_generated.go.-out-prefix to prefix the generated NewOptions and Option...Setter types.Example for MyService (myservice_options.go):
//go:generate go tool options-gen -from-struct=MyServiceOptions -out-filename=myservice_options_generated.go -out-prefix=MyService
type MyServiceOptions struct {
timeout time.Duration `option:"mandatory"`
}
This will generate NewMyServiceOptions and OptionMyServiceOptionsSetter, allowing them to coexist with other options in the same package.