VOL-1577 - General cleanup (gofmt, go vet, go test, dep check)

Change-Id: I536b2746b8bd266f3e75aeccc65bfe7468f1b44a
diff --git a/afrouter/afrouter/api.go b/afrouter/afrouter/api.go
index aec1221..36e79a3 100644
--- a/afrouter/afrouter/api.go
+++ b/afrouter/afrouter/api.go
@@ -18,25 +18,24 @@
 package afrouter
 
 import (
-	"net"
-	"fmt"
 	"errors"
-	"runtime"
-	"strconv"
-	"google.golang.org/grpc"
-	"golang.org/x/net/context"
+	"fmt"
 	"github.com/opencord/voltha-go/common/log"
 	pb "github.com/opencord/voltha-protos/go/afrouter"
+	"golang.org/x/net/context"
+	"google.golang.org/grpc"
+	"net"
+	"runtime"
+	"strconv"
 )
 
-
 type ArouterApi struct {
-	addr string
-	port int
+	addr        string
+	port        int
 	apiListener net.Listener
-	apiServer * grpc.Server
-	running bool
-	ar *ArouterProxy
+	apiServer   *grpc.Server
+	running     bool
+	ar          *ArouterProxy
 }
 
 func newApi(config *ApiConfig, ar *ArouterProxy) (*ArouterApi, error) {
@@ -51,23 +50,23 @@
 		return nil, errors.New("Errors in API configuration")
 	} else {
 		var err error = nil
-		aa := &ArouterApi{addr:config.Addr,port:int(config.Port),ar:ar}
+		aa := &ArouterApi{addr: config.Addr, port: int(config.Port), ar: ar}
 		// Create the listener for the API server
 		if aa.apiListener, err =
-			net.Listen("tcp", config.Addr + ":"+
-			strconv.Itoa(int(config.Port))); err != nil {
+			net.Listen("tcp", config.Addr+":"+
+				strconv.Itoa(int(config.Port))); err != nil {
 			log.Error(err)
 			return nil, err
 		}
 		// Create the API server
 		aa.apiServer = grpc.NewServer()
 		pb.RegisterConfigurationServer(aa.apiServer, *aa)
-		return aa,err
+		return aa, err
 	}
 }
 
 func (aa *ArouterApi) getServer(srvr string) (*server, error) {
-	if s,ok := aa.ar.servers[srvr]; ok == false {
+	if s, ok := aa.ar.servers[srvr]; ok == false {
 		err := errors.New(fmt.Sprintf("Server '%s' doesn't exist", srvr))
 		return nil, err
 	} else {
@@ -76,8 +75,8 @@
 }
 
 func (aa *ArouterApi) getRouter(s *server, clstr string) (Router, error) {
-	for _,pkg := range s.routers {
-		for  _,r := range pkg {
+	for _, pkg := range s.routers {
+		for _, r := range pkg {
 			if c := r.FindBackendCluster(clstr); c != nil {
 				return r, nil
 			}
@@ -88,8 +87,8 @@
 }
 
 func (aa *ArouterApi) getCluster(s *server, clstr string) (*backendCluster, error) {
-	for _,pkg := range s.routers {
-		for  _,r := range pkg {
+	for _, pkg := range s.routers {
+		for _, r := range pkg {
 			if c := r.FindBackendCluster(clstr); c != nil {
 				return c, nil
 			}
@@ -100,18 +99,18 @@
 }
 
 func (aa *ArouterApi) getBackend(c *backendCluster, bknd string) (*backend, error) {
-	for _,b := range c.backends {
+	for _, b := range c.backends {
 		if b.name == bknd {
-			return b,nil
+			return b, nil
 		}
 	}
 	err := errors.New(fmt.Sprintf("Backend '%s' doesn't exist in cluster %s",
-						bknd, c.name))
+		bknd, c.name))
 	return nil, err
 }
 
 func (aa *ArouterApi) getConnection(b *backend, con string) (*beConnection, error) {
-	if c,ok := b.connections[con]; ok == false {
+	if c, ok := b.connections[con]; ok == false {
 		err := errors.New(fmt.Sprintf("Connection '%s' doesn't exist", con))
 		return nil, err
 	} else {
@@ -119,8 +118,8 @@
 	}
 }
 
-func (aa * ArouterApi) updateConnection(in *pb.Conn, cn *beConnection, b *backend) error {
-	sPort := strconv.FormatUint(in.Port,10)
+func (aa *ArouterApi) updateConnection(in *pb.Conn, cn *beConnection, b *backend) error {
+	sPort := strconv.FormatUint(in.Port, 10)
 	// Check that the ip address and or port are different
 	if in.Addr == cn.addr && sPort == cn.port {
 		err := errors.New(fmt.Sprintf("Refusing to change connection '%s' to identical values", in.Connection))
@@ -135,7 +134,7 @@
 }
 
 func (aa ArouterApi) SetAffinity(ctx context.Context, in *pb.Affinity) (*pb.Result, error) {
-	log.Debugf("SetAffinity called! %v",in);
+	log.Debugf("SetAffinity called! %v", in)
 	//return &pb.Result{Success:true,Error:""},nil
 	// Navigate down tot he connection and compare IP addresses and ports if they're
 	// not the same then close the existing connection. If they are bothe the same
@@ -144,33 +143,33 @@
 
 	aap := &aa
 
-	_=aap
+	_ = aap
 
 	log.Debugf("Getting router %s and route %s", in.Router, in.Route)
-	if r,ok := allRouters[in.Router+in.Route]; ok == true {
+	if r, ok := allRouters[in.Router+in.Route]; ok == true {
 		switch rr := r.(type) {
-			case AffinityRouter:
-				log.Debug("Affinity router found")
-				b := rr.FindBackendCluster(in.Cluster).getBackend(in.Backend)
-				if b != nil {
-					rr.setAffinity(in.Id, b)
-				} else {
-					log.Errorf("Requested backend '%s' not found", in.Backend)
-				}
-				_ = rr
-			case MethodRouter:
-				log.Debug("Method router found")
-				_ = rr
-			default:
-				log.Debug("Some other router found")
-				_ = rr
+		case AffinityRouter:
+			log.Debug("Affinity router found")
+			b := rr.FindBackendCluster(in.Cluster).getBackend(in.Backend)
+			if b != nil {
+				rr.setAffinity(in.Id, b)
+			} else {
+				log.Errorf("Requested backend '%s' not found", in.Backend)
+			}
+			_ = rr
+		case MethodRouter:
+			log.Debug("Method router found")
+			_ = rr
+		default:
+			log.Debug("Some other router found")
+			_ = rr
 		}
 	} else {
 		log.Debugf("Couldn't get router type")
-		return &pb.Result{Success:false,Error:err.Error()}, err
+		return &pb.Result{Success: false, Error: err.Error()}, err
 	}
 
-	return &pb.Result{Success:true,Error:""},nil
+	return &pb.Result{Success: true, Error: ""}, nil
 }
 
 func (aa ArouterApi) SetConnection(ctx context.Context, in *pb.Conn) (*pb.Result, error) {
@@ -179,47 +178,47 @@
 	// then return an error describing the situation.
 	var s *server
 	var c *backendCluster
-	var b * backend
-	var cn * beConnection
+	var b *backend
+	var cn *beConnection
 	var err error
 
-	log.Debugf("SetConnection called! %v",in);
+	log.Debugf("SetConnection called! %v", in)
 
 	aap := &aa
-	if s,err = (aap).getServer(in.Server); err != nil {
+	if s, err = (aap).getServer(in.Server); err != nil {
 		err := errors.New(fmt.Sprintf("Server '%s' doesn't exist", in.Server))
 		log.Error(err)
-		return &pb.Result{Success:false,Error:err.Error()}, err
+		return &pb.Result{Success: false, Error: err.Error()}, err
 	}
 	// The cluster is usually accessed via tha router but since each
 	// cluster is unique it's good enough to find the router that
 	// has the cluster we're looking for rather than fully keying
 	// the path
-	if c,err = aap.getCluster(s, in.Cluster); err != nil {
+	if c, err = aap.getCluster(s, in.Cluster); err != nil {
 		log.Error(err)
-		return &pb.Result{Success:false,Error:err.Error()}, err
+		return &pb.Result{Success: false, Error: err.Error()}, err
 	}
 
-	if b,err = aap.getBackend(c, in.Backend); err != nil {
+	if b, err = aap.getBackend(c, in.Backend); err != nil {
 		log.Error(err)
-		return &pb.Result{Success:false,Error:err.Error()}, err
+		return &pb.Result{Success: false, Error: err.Error()}, err
 	}
 
-	if cn,err = aap.getConnection(b, in.Connection); err != nil {
+	if cn, err = aap.getConnection(b, in.Connection); err != nil {
 		log.Error(err)
-		return &pb.Result{Success:false,Error:err.Error()}, err
+		return &pb.Result{Success: false, Error: err.Error()}, err
 	}
 
 	if err = aap.updateConnection(in, cn, b); err != nil {
 		log.Error(err)
-		return &pb.Result{Success:false,Error:err.Error()}, err
+		return &pb.Result{Success: false, Error: err.Error()}, err
 	}
 
-	return &pb.Result{Success:true,Error:""},nil
+	return &pb.Result{Success: true, Error: ""}, nil
 }
 
 func (aa ArouterApi) GetGoroutineCount(ctx context.Context, in *pb.Empty) (*pb.Count, error) {
-	return &pb.Count{Count:uint32(runtime.NumGoroutine())}, nil
+	return &pb.Count{Count: uint32(runtime.NumGoroutine())}, nil
 }
 
 func (aa *ArouterApi) serve() {
@@ -233,4 +232,3 @@
 		}
 	}()
 }
-