Documentation
¶
Overview ¶
Package contextutil provides context helpers. Package contextutil 提供 context 辅助函数。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithTimeout ¶
func WithTimeout[T any](parent context.Context, d time.Duration, fn func(context.Context) (T, error)) (T, error)
WithTimeout calls fn synchronously with context.WithTimeout(parent, d) and cancels the context when fn finishes. Timeout handling depends on fn observing the context. WithTimeout 使用 context.WithTimeout(parent, d) 同步调用 fn,并在 fn 结束时取消 context。 超时处理依赖 fn 响应 context。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.