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 }