Help us shape the future of Go! Take the 2026 Go Developer Survey

contexthelpers

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 1 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextDispatcher

type ContextDispatcher[T any] interface {
	// Set stores the value in the context and returns a new context.
	Set(ctx context.Context, value T) context.Context

	// Get retrieves the value from the context. If the value is not set, it returns the zero value of T.
	Get(ctx context.Context) T

	// Lookup retrieves the value from the context and returns a boolean indicating if the value was found.
	Lookup(ctx context.Context) (T, bool)
}

ContextDispatcher is a generic interface for setting and getting values from context.Context.

func NewContextDispatcher

func NewContextDispatcher[T any, R comparable](key R) ContextDispatcher[T]

NewContextDispatcher creates a new ContextDispatcher with the given key.

Jump to

Keyboard shortcuts

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