2020-07-26 17:09:05 +08:00
|
|
|
package contextx
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type valueOnlyContext struct {
|
|
|
|
context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (valueOnlyContext) Deadline() (deadline time.Time, ok bool) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (valueOnlyContext) Done() <-chan struct{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (valueOnlyContext) Err() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-18 18:00:20 +08:00
|
|
|
// ValueOnlyFrom takes all values from the given ctx, without deadline and error control.
|
2020-07-26 17:09:05 +08:00
|
|
|
func ValueOnlyFrom(ctx context.Context) context.Context {
|
|
|
|
return valueOnlyContext{
|
|
|
|
Context: ctx,
|
|
|
|
}
|
|
|
|
}
|