Name return values to prevent the need (and unnecessary code bloat) (#4576)

This is done to explicitly instantiate objects for every return statement.
This commit is contained in:
Frank Wessels
2017-06-21 19:53:09 -07:00
committed by Harshavardhana
parent cec8b238f3
commit 46897b1100
24 changed files with 304 additions and 306 deletions
+4 -4
View File
@@ -69,9 +69,9 @@ type natsIOConn struct {
// dialNATS - dials and returns an natsIOConn instance,
// for sending notifications. Returns error if nats logger
// is not enabled.
func dialNATS(natsL natsNotify, testDial bool) (natsIOConn, error) {
func dialNATS(natsL natsNotify, testDial bool) (nioc natsIOConn, e error) {
if !natsL.Enable {
return natsIOConn{}, errNotifyNotEnabled
return nioc, errNotifyNotEnabled
}
// Construct natsIOConn which holds all NATS connection information
@@ -105,7 +105,7 @@ func dialNATS(natsL natsNotify, testDial bool) (natsIOConn, error) {
// Do the real connection to the NATS server
sc, err := stan.Connect(natsL.Streaming.ClusterID, clientID, connOpts...)
if err != nil {
return natsIOConn{}, err
return nioc, err
}
// Save the created connection
conn.stanConn = sc
@@ -120,7 +120,7 @@ func dialNATS(natsL natsNotify, testDial bool) (natsIOConn, error) {
// Do the real connection
nc, err := natsC.Connect()
if err != nil {
return natsIOConn{}, err
return nioc, err
}
// Save the created connection
conn.natsConn = nc