Debian Codegraph @

debian/go/src/github.com/modelcontextprotocol/go-sdk/internal/xcontext/xcontext.go

raw symbols SCIP
1 // Copyright 2019 The Go MCP SDK Authors. All rights reserved.
2 // Use of this source code is governed by an MIT-style
3 // license that can be found in the LICENSE file.
4
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.
7 package xcontext
8
9 import (
10 "context"
11 "time"
12 )
13
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} }
17
18 type detachedContext struct{ parent context.Context }
19
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 any) any { return v.parent.Value(key) }