p := 0; p < c.Parallel; p++ { s := p * chunkSize e := s + (chunkSize - 1) if p == c.Parallel-1 { e += surplus } i := p eg.Go(func() error { return rangeGet(ctx, url, s, e, i, tempFiles) }) } h"ps:/ /github.com/gopherdojo/dojo1/blob/kadai3-2-shiimaxx/kadai3/shiimaxx/range-access/gurl/gurl.go#L79-L92 Gopherಓ#1 LTେձ 2018/05/28 - Yoshima Takatada / @shiimaxx
and has no deadline. It is not // struct{}, since vars of this type must have distinct addresses. type emptyCtx int func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { return } func (*emptyCtx) Done() <-chan struct{} { return nil } func (*emptyCtx) Err() error { return nil } func (*emptyCtx) Value(key interface{}) interface{} { return nil } • h#ps:/ /github.com/golang/go/blob/release-branch.go1.10/src/context/context.go#L167-L195 Gopherಓ#1 LTେձ 2018/05/28 - Yoshima Takatada / @shiimaxx
also cancels any children // that implement canceler. type cancelCtx struct { Context mu sync.Mutex // protects following fields done chan struct{} // created lazily, closed by first cancel call children map[canceler]struct{} // set to nil by the first cancel call err error // set to non-nil by the first cancel call } func (c *cancelCtx) Done() <-chan struct{} { c.mu.Lock() if c.done == nil { c.done = make(chan struct{}) } d := c.done c.mu.Unlock() return d } func (c *cancelCtx) Err() error { c.mu.Lock() defer c.mu.Unlock() return c.err } func (c *cancelCtx) String() string { return fmt.Sprintf("%v.WithCancel", c.Context) } • h#ps:/ /github.com/golang/go/blob/release-branch.go1.10/src/context/context.go#L314-L343 Gopherಓ#1 LTେձ 2018/05/28 - Yoshima Takatada / @shiimaxx