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

Change-Id: I536b2746b8bd266f3e75aeccc65bfe7468f1b44a
diff --git a/afrouter/afrouter/config.go b/afrouter/afrouter/config.go
index a9a01eb..2cc2976 100644
--- a/afrouter/afrouter/config.go
+++ b/afrouter/afrouter/config.go
@@ -19,27 +19,27 @@
 
 // Command line parameters and parsing
 import (
-	"os"
-	"fmt"
-	"flag"
-	"path"
-	"errors"
-	"io/ioutil"
 	"encoding/json"
+	"errors"
+	"flag"
+	"fmt"
 	"github.com/opencord/voltha-go/common/log"
+	"io/ioutil"
+	"os"
+	"path"
 )
 
 func ParseCmd() (*Configuration, error) {
 	config := &Configuration{}
-	cmdParse := flag.NewFlagSet(path.Base(os.Args[0]), flag.ContinueOnError);
+	cmdParse := flag.NewFlagSet(path.Base(os.Args[0]), flag.ContinueOnError)
 	config.ConfigFile = cmdParse.String("config", "arouter.json", "The configuration file for the affinity router")
 	config.LogLevel = cmdParse.Int("logLevel", 0, "The log level for the affinity router")
 	config.GrpcLog = cmdParse.Bool("grpclog", false, "Enable GRPC logging")
 
-	err := cmdParse.Parse(os.Args[1:]);
+	err := cmdParse.Parse(os.Args[1:])
 	if err != nil {
 		//return err
-		return nil, errors.New("Error parsing the command line");
+		return nil, errors.New("Error parsing the command line")
 	}
 	//if(!cmdParse.Parsed()) {
 	//}
@@ -48,72 +48,71 @@
 
 // Configuration file loading and parsing
 type Configuration struct {
-	ConfigFile * string
-	LogLevel * int
-	GrpcLog * bool
-	Servers []ServerConfig `json:"servers"`
-	Ports PortConfig `json:"ports"`
-	ServerCertificates ServerCertConfig `json:"serverCertificates"`
-	ClientCertificates ClientCertConfig `json:"clientCertificates"`
-	BackendClusters []BackendClusterConfig `json:"backend_clusters"`
-	Routers []RouterConfig `json:"routers"`
-	Api ApiConfig
+	ConfigFile         *string
+	LogLevel           *int
+	GrpcLog            *bool
+	Servers            []ServerConfig         `json:"servers"`
+	Ports              PortConfig             `json:"ports"`
+	ServerCertificates ServerCertConfig       `json:"serverCertificates"`
+	ClientCertificates ClientCertConfig       `json:"clientCertificates"`
+	BackendClusters    []BackendClusterConfig `json:"backend_clusters"`
+	Routers            []RouterConfig         `json:"routers"`
+	Api                ApiConfig
 }
 
 type RouterConfig struct {
-	Name string `json:"name"`
-	ProtoService string `json:"service"`
-	ProtoPackage string `json:"package"`
-	Routes []RouteConfig `json:"routes"`
+	Name         string        `json:"name"`
+	ProtoService string        `json:"service"`
+	ProtoPackage string        `json:"package"`
+	Routes       []RouteConfig `json:"routes"`
 }
 
 type RouteConfig struct {
-	Name string `json:"name"`
-	Type string `json:"type"`
-	ProtoFile string `json:"proto_descriptor"`
-	Association string `json:"association"`
-	RouteField string `json:"routing_field"`
-	Methods []string `json:"methods"` // The GRPC methods to route using the route field
-	NbBindingMethods []string `json:"nb_binding_methods"`
-	BackendCluster string `json:"backend_cluster"`
-	Binding BindingConfig `json:"binding"`
-	Overrides []OverrideConfig `json:"overrides"`
-	backendCluster *BackendClusterConfig
+	Name             string           `json:"name"`
+	Type             string           `json:"type"`
+	ProtoFile        string           `json:"proto_descriptor"`
+	Association      string           `json:"association"`
+	RouteField       string           `json:"routing_field"`
+	Methods          []string         `json:"methods"` // The GRPC methods to route using the route field
+	NbBindingMethods []string         `json:"nb_binding_methods"`
+	BackendCluster   string           `json:"backend_cluster"`
+	Binding          BindingConfig    `json:"binding"`
+	Overrides        []OverrideConfig `json:"overrides"`
+	backendCluster   *BackendClusterConfig
 }
 
 type BindingConfig struct {
-	Type string `json:"type"`
-	Field string `json:"field"`
-	Method string `json:"method"`
+	Type        string `json:"type"`
+	Field       string `json:"field"`
+	Method      string `json:"method"`
 	Association string `json:"association"`
-
 }
 
 type OverrideConfig struct {
-	Methods []string `json:"methods"`
-	Method string `json:"method"`
-	RouteField string `json:"routing_field"`
+	Methods    []string `json:"methods"`
+	Method     string   `json:"method"`
+	RouteField string   `json:"routing_field"`
 }
 
 // Backend configuration
 
 type BackendClusterConfig struct {
-	Name string `json:"name"`
+	Name     string          `json:"name"`
 	Backends []BackendConfig `json:"backends"`
 }
 
 type BackendConfig struct {
-	Name string `json:"name"`
-	Type string `json:"type"`
-	Association AssociationConfig `json:"association"`
+	Name        string             `json:"name"`
+	Type        string             `json:"type"`
+	Association AssociationConfig  `json:"association"`
 	Connections []ConnectionConfig `json:"connections"`
 }
 
 type AssociationConfig struct {
 	Strategy string `json:"strategy"`
 	Location string `json:"location"`
-	Field string `json:"field"`
-	Key string `json:"key"`
+	Field    string `json:"field"`
+	Key      string `json:"key"`
 }
 
 type ConnectionConfig struct {
@@ -125,51 +124,51 @@
 // Server configuration
 
 type ServerConfig struct {
-	Name string `json:"name"`
-	Port uint `json:"port"`
-	Addr string `json:"address"`
-	Type string `json:"type"`
+	Name    string          `json:"name"`
+	Port    uint            `json:"port"`
+	Addr    string          `json:"address"`
+	Type    string          `json:"type"`
 	Routers []RouterPackage `json:"routers"`
 	routers map[string]*RouterConfig
 }
 
 type RouterPackage struct {
-	Router string `json:"router"`
+	Router  string `json:"router"`
 	Package string `json:"package"`
 }
 
 // Port configuration
 type PortConfig struct {
-	GrpcPort uint `json:"grpcPort"`
-	StreamingGrpcPort uint `json:"streamingGrpcPort"`
-	TlsGrpcPort uint `json:"tlsGrpcPort"`
+	GrpcPort             uint `json:"grpcPort"`
+	StreamingGrpcPort    uint `json:"streamingGrpcPort"`
+	TlsGrpcPort          uint `json:"tlsGrpcPort"`
 	TlsStreamingGrpcPort uint `json:"tlsStreamingGrpcPort"`
-	ControlPort uint `json:"controlPort"`
+	ControlPort          uint `json:"controlPort"`
 }
 
 // Server Certificate configuration
 type ServerCertConfig struct {
-	GrpcCert string `json:"grpcCertificate"`	// File path to the certificate file
-	GrpcKey string `json:"grpcKey"`			// File path to the key file
-	GrpcCsr string `json:"grpcCsr"`			// File path to the CSR file
+	GrpcCert string `json:"grpcCertificate"` // File path to the certificate file
+	GrpcKey  string `json:"grpcKey"`         // File path to the key file
+	GrpcCsr  string `json:"grpcCsr"`         // File path to the CSR file
 }
 
 // Client Certificate configuration
 type ClientCertConfig struct {
-	GrpcCert string `json:"grpcCertificate"`	// File path to the certificate file
-	GrpcKey string `json:"grpcKey"`			// File path to the key file
-	GrpcCsr string `json:"grpcCsr"`			// File path to the CSR file
+	GrpcCert string `json:"grpcCertificate"` // File path to the certificate file
+	GrpcKey  string `json:"grpcKey"`         // File path to the key file
+	GrpcCsr  string `json:"grpcCsr"`         // File path to the CSR file
 }
 
 // Api configuration
 type ApiConfig struct {
 	Addr string `json:"address"`
-	Port uint `json:"port"`
+	Port uint   `json:"port"`
 }
 
-func (conf * Configuration) LoadConfig() error {
+func (conf *Configuration) LoadConfig() error {
 
-	configF, err := os.Open(*conf.ConfigFile);
+	configF, err := os.Open(*conf.ConfigFile)
 	log.Info("Loading configuration from: ", *conf.ConfigFile)
 	if err != nil {
 		log.Error(err)
@@ -195,25 +194,25 @@
 	// references to backend_cluster in the routers.
 
 	// Resolve router references for the servers
-	log.Debug("Resolving references in the config file");
-	for k,_ := range conf.Servers {
+	log.Debug("Resolving references in the config file")
+	for k, _ := range conf.Servers {
 		//s.routers =make(map[string]*RouterConfig)
 		conf.Servers[k].routers = make(map[string]*RouterConfig)
-		for _,rPkg := range conf.Servers[k].Routers {
+		for _, rPkg := range conf.Servers[k].Routers {
 			var found bool = false
 			// Locate the router "r" in the top lever Routers array
-			log.Debugf("Resolving router reference to router '%s' from server '%s'",rPkg.Router, conf.Servers[k].Name)
+			log.Debugf("Resolving router reference to router '%s' from server '%s'", rPkg.Router, conf.Servers[k].Name)
 			for rk, _ := range conf.Routers {
 				if conf.Routers[rk].Name == rPkg.Router && !found {
 					log.Debugf("Reference to router '%s' found for package '%s'", rPkg.Router, rPkg.Package)
 					conf.Servers[k].routers[rPkg.Package] = &conf.Routers[rk]
 					found = true
 				} else if conf.Routers[rk].Name == rPkg.Router && found {
-					if _,ok := conf.Servers[k].routers[rPkg.Package]; !ok {
+					if _, ok := conf.Servers[k].routers[rPkg.Package]; !ok {
 						log.Debugf("Reference to router '%s' found for package '%s'", rPkg.Router, rPkg.Package)
 						conf.Servers[k].routers[rPkg.Package] = &conf.Routers[rk]
 					} else {
-						err := errors.New(fmt.Sprintf("Duplicate router '%s' defined for package '%s'",rPkg.Router, rPkg.Package))
+						err := errors.New(fmt.Sprintf("Duplicate router '%s' defined for package '%s'", rPkg.Router, rPkg.Package))
 						log.Error(err)
 						return err
 					}
@@ -228,30 +227,29 @@
 	}
 
 	// Resolve backend references for the routers
-	for rk,rv := range conf.Routers {
-		for rtk,rtv := range rv.Routes {
+	for rk, rv := range conf.Routers {
+		for rtk, rtv := range rv.Routes {
 			var found bool = false
-			log.Debugf("Resolving backend reference to %s from router %s",rtv.BackendCluster, rv.Name)
-			for bek,bev := range conf.BackendClusters {
+			log.Debugf("Resolving backend reference to %s from router %s", rtv.BackendCluster, rv.Name)
+			for bek, bev := range conf.BackendClusters {
 				log.Debugf("Checking cluster %s", conf.BackendClusters[bek].Name)
 				if rtv.BackendCluster == bev.Name && !found {
 					conf.Routers[rk].Routes[rtk].backendCluster = &conf.BackendClusters[bek]
 					found = true
 				} else if rtv.BackendCluster == bev.Name && found {
-					err := errors.New(fmt.Sprintf("Duplicate backend defined, %s",conf.BackendClusters[bek].Name))
+					err := errors.New(fmt.Sprintf("Duplicate backend defined, %s", conf.BackendClusters[bek].Name))
 					log.Error(err)
 					return err
 				}
 			}
-			if !found  {
+			if !found {
 				err := errors.New(fmt.Sprintf("Backend %s for router %s not found in config",
-									rtv.BackendCluster, rv.Name))
+					rtv.BackendCluster, rv.Name))
 				log.Error(err)
 				return err
 			}
 		}
 	}
 
-
 	return nil
 }