mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-24 03:29:05 +08:00
36 lines
646 B
Go
36 lines
646 B
Go
// Package contexts
|
|
// @Link https://github.com/bufanyun/hotgo
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
|
// @Author Ms <133814250@qq.com>
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
package contexts
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type detached struct {
|
|
ctx context.Context
|
|
}
|
|
|
|
func (detached) Deadline() (time.Time, bool) {
|
|
return time.Time{}, false
|
|
}
|
|
|
|
func (detached) Done() <-chan struct{} {
|
|
return nil
|
|
}
|
|
|
|
func (detached) Err() error {
|
|
return nil
|
|
}
|
|
|
|
func (d detached) Value(key interface{}) interface{} {
|
|
return d.ctx.Value(key)
|
|
}
|
|
|
|
func Detach(ctx context.Context) context.Context {
|
|
return detached{ctx: ctx}
|
|
}
|