keys

package
v0.0.0-...-6c7272e Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package keys holds code for managing the set of common keys in a context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(ctx context.Context, key interface{}, value interface{}) context.Context

Chain adds a new link to a value chain for the specified key.

func Clone

func Clone(ctx context.Context, from context.Context) context.Context

Clone copies values from one context to another. This is used to produce associated but detached contexts.

func Get

func Get(ctx context.Context) []interface{}

Get returns the list of potential keys to use.

func WithValue

func WithValue(ctx context.Context, key interface{}, value interface{}) context.Context

WithValue registers the key as well as adding the value to the context.

Types

type Link struct {
	Value interface{}
	Next  *Link
}

Link is the type for a link in a chain of values. This is used for values where you want to maintain the full list of values stored against that key, rather than just the most recently assigned value.

func (*Link) Format

func (l *Link) Format(f fmt.State, r rune)

Format implements fmt.Formatter to print the full value chain.

Jump to

Keyboard shortcuts

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