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
+3 -3
View File
@@ -50,9 +50,9 @@ type mqttConn struct {
Client MQTT.Client
}
func dialMQTT(mqttL mqttNotify) (mqttConn, error) {
func dialMQTT(mqttL mqttNotify) (mc mqttConn, e error) {
if !mqttL.Enable {
return mqttConn{}, errNotifyNotEnabled
return mc, errNotifyNotEnabled
}
connOpts := &MQTT.ClientOptions{
ClientID: mqttL.ClientID,
@@ -66,7 +66,7 @@ func dialMQTT(mqttL mqttNotify) (mqttConn, error) {
connOpts.AddBroker(mqttL.Broker)
client := MQTT.NewClient(connOpts)
if token := client.Connect(); token.Wait() && token.Error() != nil {
return mqttConn{}, token.Error()
return mc, token.Error()
}
return mqttConn{Client: client, params: mqttL}, nil
}