problem description
in the actual development of golang, whether the Dial, of grpc needs to be closed or not, it can be done in init () if it does not need to be closed. It is better to keep the connection pool long when the connection is closed frequently.
related codes
func init() {
once.Do(func() {
var err error
conn, err = grpc.Dial(config.ServerURL, grpc.WithInsecure())
if err != nil {
logger.Err(err, "Gateway Dial ")
}
//grpcconncloseconnect
//tcp
//deferinit()
//defer conn.Close()
})
}