github.com/lingyao2333/mo-zero@v1.4.1/core/contextx/valueonlycontext.go (about)

     1  package contextx
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  )
     7  
     8  type valueOnlyContext struct {
     9  	context.Context
    10  }
    11  
    12  func (valueOnlyContext) Deadline() (deadline time.Time, ok bool) {
    13  	return
    14  }
    15  
    16  func (valueOnlyContext) Done() <-chan struct{} {
    17  	return nil
    18  }
    19  
    20  func (valueOnlyContext) Err() error {
    21  	return nil
    22  }
    23  
    24  // ValueOnlyFrom takes all values from the given ctx, without deadline and error control.
    25  func ValueOnlyFrom(ctx context.Context) context.Context {
    26  	return valueOnlyContext{
    27  		Context: ctx,
    28  	}
    29  }