Skip to content

๐Ÿ” Inspect private context.Context internals

License

Notifications You must be signed in to change notification settings

joshdk/contents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

License GoDoc Go Report Card CircleCI CodeCov

Contents

๐Ÿ” Inspect private context.Context internals

Installing

You can fetch this library by running the following

go get -u github.com/joshdk/contents

Usage

import (
	"context"
	"fmt"
	"github.com/joshdk/contents"
)

// Build a context
ctx := context.Background()
ctx = context.WithValue(ctx, "key-1", "val-1")
ctx = context.WithValue(ctx, "key-2", "val-2")
ctx = context.WithValue(ctx, "key-3", "val-3")

// Extract list of all keys
keys := contents.Keys(ctx)

for _, key := range keys {
	fmt.Printf("Context contains %q โ†’ %q\n", key, ctx.Value(key))
	// Context contains "key-1" โ†’ "val-1"
	// Context contains "key-2" โ†’ "val-2"
	// Context contains "key-3" โ†’ "val-3"
}

License

This library is distributed under the MIT License, see LICENSE.txt for more information.

About

๐Ÿ” Inspect private context.Context internals

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published