opt

package
v0.19.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package opt provides a small generic implementation of the functional options pattern. Option[T] is a function that mutates a value of type T and may return an error; Options[T] is a slice of them whose Apply method runs each option in order and stops at the first error. It lets constructors accept a variadic ...Option[T] for type-safe, composable configuration without per-type boilerplate. Code generated by apic; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option[T any] func(T) error

Option is a single functional-option function: it mutates v (typically a pointer or other reference type) and may return an error to abort construction.

func (Option[T]) Apply

func (o Option[T]) Apply(v T) error

Apply invokes o against v, returning whatever error o produces.

type Options

type Options[T any] []Option[T]

Options is an ordered slice of Option[T] values to apply together.

func (Options[T]) Apply

func (o Options[T]) Apply(v T) error

Apply runs every Option in o against v, in order, stopping and returning the first error encountered. Returns nil if every option succeeds (including when o is empty).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL