Golang grpc: how to recover the grpc server from panic?
<p>I have a handler like this:</p>

<pre><code>func (daemon *Daemon) List(item string) (map[string][]string, error) {
      panic("this is a panic")
      ...
</code></pre>

<p>I just want to recover this potential panic, so in my grpc server I wrote:</p>

<pre><code>// Serve serves gRPC request by goroutines
func (s *ServerRPC) Serve(addr string) error {
    defer func() {
        if err := recover(); err != nil {
            glog.Errorf("Recovered from err: ", err)
        }
    }()

    l, err := net.Listen("tcp", addr)
    if err != nil {
        glog.Fatalf("Failed to listen %s: %v", addr, err)
        return err
    }

    return s.server.Serve(l)
}
</code></pre>

<p>But it does not capture the panic, I thought it was because my panic happened in child goroutines? If so, how can I recover my grpc server from crashing properly?</p>