WithStackValue adds a key value pair to the context that is intended to be scoped to a stack. Use ClearStackValues to get a new context with all stack values cleared.
(ctx context.Context, key, value interface{})
| 10 | // scoped to a stack. Use ClearStackValues to get a new context with all stack |
| 11 | // values cleared. |
| 12 | func WithStackValue(ctx context.Context, key, value interface{}) context.Context { |
| 13 | md, _ := ctx.Value(stackValuesKey{}).(*stackValues) |
| 14 | |
| 15 | md = withStackValue(md, key, value) |
| 16 | return context.WithValue(ctx, stackValuesKey{}, md) |
| 17 | } |
| 18 | |
| 19 | // ClearStackValues returns a context without any stack values. |
| 20 | func ClearStackValues(ctx context.Context) context.Context { |