go---context

context包中有以下4个函数
  1. func WithCancel(parent Context) (ctx Context, cancel CancelFunc){}
  2. func WithDeadline(parent Context, d time.Time) (Context, CancelFunc){}//在d时或其之前调用cancel函数
  3. func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc){}//在timeout后调用cancel函数
  4. func WithValue(parent Context, key, val interface{}) Context{}//将key-value和context绑定在一起

猜你喜欢

转载自www.cnblogs.com/zhao1070285683/p/10430130.html