Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshdk/contents
🔍 Inspect private context.Context internals
https://github.com/joshdk/contents
context golang reflect
Last synced: about 5 hours ago
JSON representation
🔍 Inspect private context.Context internals
- Host: GitHub
- URL: https://github.com/joshdk/contents
- Owner: joshdk
- License: mit
- Created: 2017-11-15T23:40:30.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-17T03:09:21.000Z (almost 7 years ago)
- Last Synced: 2024-06-20T05:16:35.468Z (5 months ago)
- Topics: context, golang, reflect
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![License](https://img.shields.io/github/license/joshdk/contents.svg)](https://opensource.org/licenses/MIT)
[![GoDoc](https://godoc.org/github.com/joshdk/contents?status.svg)](https://godoc.org/github.com/joshdk/contents)
[![Go Report Card](https://goreportcard.com/badge/github.com/joshdk/contents)](https://goreportcard.com/report/github.com/joshdk/contents)
[![CircleCI](https://circleci.com/gh/joshdk/contents.svg?&style=shield)](https://circleci.com/gh/joshdk/contents/tree/master)
[![CodeCov](https://codecov.io/gh/joshdk/contents/branch/master/graph/badge.svg)](https://codecov.io/gh/joshdk/contents)# Contents
🔍 Inspect private context.Context internals
## Installing
You can fetch this library by running the following
go get -u github.com/joshdk/contents
## Usage
```go
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](https://opensource.org/licenses/MIT), see LICENSE.txt for more information.