Call wg.Add in main goroutine to avoid race conditons.
@@ -109,8 +109,8 @@ func (t Transfer) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
ch := make(chan *dns.Envelope)
tr := new(dns.Transfer)
wg := new(sync.WaitGroup)
- go func() {
wg.Add(1)
+ go func() {
tr.Out(w, r, ch)
wg.Done()
}()
