Produced with a patched version of modernize containing only the efaceany pass: $ go run ./gopls/internal/analysis/modernize/cmd/modernize/main.go -test -fix ./... ./gopls/... This is very safe and forms the bulk of the modernize diff, isolating the other changes for ease of review. Change-Id: Iec9352bac5a639a5c03368427531c7842c6e9ad0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/650759 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Alan Donovan <adonovan@google.com>
23 lines
944 B
Go
23 lines
944 B
Go
// Copyright 2019 The Go MCP SDK Authors. All rights reserved.
|
|
// Use of this source code is governed by an MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Package xcontext is a package to offer the extra functionality we need
|
|
// from contexts that is not available from the standard context package.
|
|
package xcontext
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// Detach returns a context that keeps all the values of its parent context
|
|
// but detaches from the cancellation and error handling.
|
|
func Detach(ctx context.Context) context.Context { return detachedContext{ctx} }
|
|
|
|
type detachedContext struct{ parent context.Context }
|
|
|
|
func (v detachedContext) Deadline() (time.Time, bool) { return time.Time{}, false }
|
|
func (v detachedContext) Done() <-chan struct{} { return nil }
|
|
func (v detachedContext) Err() error { return nil }
|
|
func (v detachedContext) Value(key any) any { return v.parent.Value(key) }
|