Closed QiAnXinCodeSafe closed 5 years ago
The defer statement must be placed after the error check. Otherwise listen may be nil. https://github.com/google/gnxi/blob/c14ccdb08c24e65e80106585d98bb07a40d65c30/gnoi_target/gnoi_target.go#L43-L47
defer statement
listen
It should not be a problem. If log.Fatal happened defer part will not be executed.
Yes, you are right. However, it is best to place the defer statement after the error check.
The
defer statement
must be placed after the error check. Otherwiselisten
may be nil. https://github.com/google/gnxi/blob/c14ccdb08c24e65e80106585d98bb07a40d65c30/gnoi_target/gnoi_target.go#L43-L47