DEV Community

loading...

Discussion on: gRPC quick start in Go

Collapse
ernsheong profile image
Jonathan ES Lin

Thanks for the reply. I figured it out. Gotta be careful with defer conn.Close() if calling outside main function... After function ends it will close the connection and the client cannot be used anymore.

Thread Thread
dannypsnl profile image
林子篆 Author

Good to hear that; yes, better to using context if you want to manage the lifecycle. It provides a not bad abstraction for stopping a goroutine.