Skip to content

Option mode #40

@a67793581

Description

@a67793581

Here's a concise English issue description for implementing the Option pattern in Go:


Title: Implement Option pattern for flexible configuration

Description:
We need to adopt the Option pattern (functional options) to improve initialization of complex structs. Current constructors suffer from:

  1. Long parameter lists
  2. Inflexible configuration
  3. Breaking changes when adding new fields

Proposed Solution:
Create option functions following this pattern:

type Option func(*Config)

func WithTimeout(t time.Duration) Option {
    return func(c *Config) {
        c.Timeout = t
    }
}

Benefits:

  • Cleaner constructor calls
  • Self-documenting parameters
  • Backward-compatible API evolution
  • Easier testing with partial configurations

Acceptance Criteria:

  1. Core struct(s) support functional options
  2. Deprecate old multi-parameter constructors
  3. Documentation examples added

Reference: Go functional options pattern


This clearly communicates the need while leaving implementation details open for discussion. Adjust struct/type names as needed for your specific context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions