func (t *mockTransport) Respond(req message.Request, rsp message.Response) error { t.RLock() rspChan, ok := t.inflightReqs[req.Id()] t.RUnlock() // Make a copy of the response that does not preserve the Body (this is not preserved over the wire) rsp = rsp.Copy() rsp.SetBody(nil) if ok { select { case rspChan <- rsp: return nil case <-time.After(timeout): return transport.ErrTimeout } } return fmt.Errorf("No correlated request \"%s\" is in-flight", req.Id()) }