Don't use := when some vars are defined

:= attempts to declare as many of the variables on its left side as it
can, instead of re-using as many as it can.  Consider this code:

   a, ok := foo()
   if !ok {
      a, err := bar()
      ...
   }

The inner 'a' is a different var from the outer one, and goes out of
scope at the }.  The outer 'a' is left with whatever value foo()
returned.
This commit is contained in:
Soam Vasani
2016-11-02 20:29:21 -07:00
parent af8e5f360f
commit bb687d3e98
+2 -1
View File
@@ -56,9 +56,10 @@ func (gpm *GenericPoolManager) service() {
for {
select {
case req := <-gpm.requestChannel:
var err error
pool, ok := gpm.pools[*req.env]
if !ok {
pool, err := MakeGenericPool(gpm.controllerUrl, gpm.kubernetesClient, req.env, 3, gpm.namespace)
pool, err = MakeGenericPool(gpm.controllerUrl, gpm.kubernetesClient, req.env, 3, gpm.namespace)
if err != nil {
req.responseChannel <- &response{error: err}
continue