mirror of
https://github.com/golang/go.git
synced 2025-05-11 02:23:00 +00:00
This adds the ability to tie a background context to the context that created it in traces, and also cleans up and annotates the context used in type checking. This gives us detailed connected traces of all the type checking and parsing logic. Change-Id: I32721220a50ecb9b4404a4e9354343389d7a5219 Reviewed-on: https://go-review.googlesource.com/c/tools/+/183757 Reviewed-by: Rebecca Stambler <rstambler@golang.org>
22 lines
826 B
Go
22 lines
826 B
Go
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package memoize
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// detatch returns a context that keeps all the values of its parent context
|
|
// but detatches from the cancellation and error handling.
|
|
func detatchContext(ctx context.Context) context.Context { return detatchedContext{ctx} }
|
|
|
|
type detatchedContext struct{ parent context.Context }
|
|
|
|
func (v detatchedContext) Deadline() (time.Time, bool) { return time.Time{}, false }
|
|
func (v detatchedContext) Done() <-chan struct{} { return nil }
|
|
func (v detatchedContext) Err() error { return nil }
|
|
func (v detatchedContext) Value(key interface{}) interface{} { return v.parent.Value(key) }
|