diff --git a/trace/tcp_ipv4.go b/trace/tcp_ipv4.go index 8e1533c3..709649a7 100644 --- a/trace/tcp_ipv4.go +++ b/trace/tcp_ipv4.go @@ -87,10 +87,13 @@ func (t *TCPTracer) Execute() (*Result, error) { time.Sleep(1 * time.Millisecond) } go func() { - for { - t.AsyncPrinter(&t.res) - time.Sleep(50 * time.Millisecond) + if t.AsyncPrinter != nil { + for { + t.AsyncPrinter(&t.res) + time.Sleep(50 * time.Millisecond) + } } + }() // 如果是表格模式,则一次性并发请求 diff --git a/trace/udp.go b/trace/udp.go index 4259186f..bd9454bc 100644 --- a/trace/udp.go +++ b/trace/udp.go @@ -70,9 +70,11 @@ func (t *UDPTracer) Execute() (*Result, error) { time.Sleep(1 * time.Millisecond) } go func() { - for { - t.AsyncPrinter(&t.res) - time.Sleep(50 * time.Millisecond) + if t.AsyncPrinter != nil { + for { + t.AsyncPrinter(&t.res) + time.Sleep(50 * time.Millisecond) + } } }() // 如果是表格模式,则一次性并发请求