From 0f8140031af3f5c7c97696feb4c37ba5198a75e0 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Fri, 18 Sep 2020 18:07:08 +0800 Subject: [PATCH] fix rpc client examle (#81) --- example/rpc/client/stream/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/example/rpc/client/stream/client.go b/example/rpc/client/stream/client.go index d680a079..55f93db8 100644 --- a/example/rpc/client/stream/client.go +++ b/example/rpc/client/stream/client.go @@ -33,8 +33,12 @@ func main() { log.Fatal(err) } + done := make(chan struct{}) go func() { - for { + defer func() { + done <- struct{}{} + }() + for i := 0; i < 3; i++ { resp, err := stm.Recv() if err != nil { log.Fatal(err) @@ -52,4 +56,6 @@ func main() { log.Fatal(err) } } + + <-done }