使用nil上下文,但不要惊慌并挂在那里。 这怎么可能呢?

type Etcd struct {
    Next       plugin.Handler
    Fall       fall.F
    Zones      []string
    PathPrefix string
    Upstream   upstream.Upstream // Proxy for looking up names during the resolution process
    Client     etcdc.KeysAPI
    Ctx        context.Context
    Stubmap    *map[string]proxy.Proxy // list of proxies for stub resolving.

    endpoints []string // Stored here as well, to aid in testing.
}


func (e *Etcd) get(path string, recursive bool) (*etcdc.Response, error) {
    if e.Ctx == nil {
            // run here
            log.Printf("e.Ctx is nil")
    }
    // hang here but not panic.
    ctx, cancel := context.WithTimeout(e.Ctx, etcdTimeout)
    defer cancel()
    r, err := e.Client.Get(ctx, path, &etcdc.GetOptions{Sort: false, Recursive: recursive})
    if err != nil {
            return nil, err
    }
    return r, nil
}

source code link: https://github.com/coredns/coredns/blob/v1.0.6/plugin/etcd/etcd.go#L87

I used this etcd package in my own project, and init it, but not initialize filed Ctx, and I found that the process hang at this code:

ctx, cancel := context.WithTimeout(e.Ctx, etcdTimeout)

how could this happen with e.Ctx is nil and context.WithTimeout() do not panic ?

Anyone's suggestion is helpful.