package
Version:
v0.4.27
Opens a new window with list of versions in this module.
Published: Aug 12, 2026
License: LGPL-2.1
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 29
Opens a new window with list of known importers.
Documentation
¶
Package option 提供泛型选项构造器。
Package option 定义了 `Setting[T]` 及其组合函数,用来实现本仓库大量使用的
`With.xxx(...)` 风格配置 API。
New 会先应用默认值,再按顺序应用额外配置;Append 和 Change 用于在现有值上继续叠加。
service、runtime、core 与 ec 包的选项体系都基于该包实现。
func Append[T any](options T, settings ...Setting[T]) T
Append 在 options 的浅拷贝上按顺序应用 settings,并返回结果。
func Change[T any](options T, settings ...Setting[T]) T
Change 在 options 的浅拷贝上按顺序应用 settings,并返回结果。
Change 当前与 Append 语义相同,用于在调用处表达“修改现有选项”的意图。
New 从 T 的零值开始,先应用 defaults,再按给定顺序应用 settings。
Setting 是按地址修改选项值的函数式设置项;nil Setting 是空操作。
func (s Setting[T]) Apply(options *T)
Apply 将设置项应用到 options。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.