1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Package xcontext is a package to offer the extra functionality we need
6 // from contexts that is not available from the standard context package.
14 // Detach returns a context that keeps all the values of its parent context
15 // but detaches from the cancellation and error handling.
16 func Detach(ctx context.Context) context.Context { return detachedContext{ctx} }
18 type detachedContext struct{ parent context.Context }
20 func (v detachedContext) Deadline() (time.Time, bool) { return time.Time{}, false }
21 func (v detachedContext) Done() <-chan struct{} { return nil }
22 func (v detachedContext) Err() error { return nil }
23 func (v detachedContext) Value(key interface{}) interface{} { return v.parent.Value(key) }