github.com/xmidt-org/webpa-common@v1.11.9/convey/context.go (about) 1 package convey 2 3 import "context" 4 5 type contextKey struct{} 6 7 func NewContext(parent context.Context, v C) context.Context { 8 return context.WithValue(parent, contextKey{}, v) 9 } 10 11 func FromContext(ctx context.Context) (C, bool) { 12 v, ok := ctx.Value(contextKey{}).(C) 13 return v, ok 14 }