From 8230fba4d32791b172e4cf7630c3d4430263e09d Mon Sep 17 00:00:00 2001
From: Manuel Kieweg <manuel.kieweg@h-da.de>
Date: Fri, 28 May 2021 18:42:13 +0200
Subject: [PATCH] golint --fix

---
 cli/capabilities.go                    | 11 +++++-----
 cli/grpc.go                            | 29 +++++++++++++-------------
 cli/grpc_test.go                       | 13 ++++++------
 cmd/getPnd.go                          |  2 +-
 cmd/list.go                            |  4 ++--
 controller.go                          |  3 ++-
 northbound/server/pnd.go               |  5 ++---
 nucleus/change.go                      |  3 ++-
 nucleus/device_test.go                 |  5 +++--
 nucleus/gnmi_transport.go              |  5 +++--
 nucleus/gnmi_transport_test.go         |  5 +++--
 nucleus/initialise_test.go             | 11 +++++-----
 nucleus/principalNetworkDomain.go      |  5 +++--
 nucleus/principalNetworkDomain_test.go | 25 +++++++++++-----------
 nucleus/transport.go                   |  3 ++-
 15 files changed, 70 insertions(+), 59 deletions(-)

diff --git a/cli/capabilities.go b/cli/capabilities.go
index f1c2d6be0..9e3518f82 100644
--- a/cli/capabilities.go
+++ b/cli/capabilities.go
@@ -1,12 +1,13 @@
 package cli
 
 import (
-	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
-	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"context"
 	"fmt"
 	"strings"
 
+	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
+	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
+
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus"
 	gpb "github.com/openconfig/gnmi/proto/gnmi"
 )
@@ -15,9 +16,9 @@ import (
 // and prints the supported models to stdout
 func Capabilities(a, u, p string) error {
 	opts := &tpb.TransportOption{
-		Address:         a,
-		Username:        u,
-		Password:        p,
+		Address:  a,
+		Username: u,
+		Password: p,
 	}
 	transport, err := nucleus.NewGnmiTransport(opts, nucleus.NewSBI(spb.Type_OPENCONFIG))
 	if err != nil {
diff --git a/cli/grpc.go b/cli/grpc.go
index e60cdf25d..bac5efa61 100644
--- a/cli/grpc.go
+++ b/cli/grpc.go
@@ -1,14 +1,15 @@
 package cli
 
 import (
+	"context"
+	"time"
+
 	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
 	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
 	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	nbi "code.fbi.h-da.de/cocsn/gosdn/northbound/client"
-	"context"
 	log "github.com/sirupsen/logrus"
 	"github.com/spf13/viper"
-	"time"
 
 	pb "code.fbi.h-da.de/cocsn/api/go/gosdn/core"
 	"google.golang.org/grpc"
@@ -36,7 +37,7 @@ func Init(addr string) error {
 	return nil
 }
 
-func GetIds(addr string) ([]*ppb.PrincipalNetworkDomain,error) {
+func GetIds(addr string) ([]*ppb.PrincipalNetworkDomain, error) {
 	ctx := context.Background()
 	resp, err := getAllCore(ctx, addr)
 	if err != nil {
@@ -65,7 +66,7 @@ func AddPnd(addr, name, description, sbi string) error {
 	ctx := context.Background()
 	req := &pb.SetRequest{
 		Timestamp: time.Now().UnixNano(),
-		Pnd:       []*pb.SetPnd{
+		Pnd: []*pb.SetPnd{
 			{
 				Name:        name,
 				Description: description,
@@ -85,7 +86,7 @@ func AddPnd(addr, name, description, sbi string) error {
 func GetPnd(addr string, args ...string) (*pb.GetResponse, error) {
 	coreClient, err := nbi.CoreClient(addr, grpcWithInsecure)
 	if err != nil {
-		return nil,err
+		return nil, err
 	}
 	ctx := context.Background()
 	req := &pb.GetRequest{
@@ -114,7 +115,7 @@ func GetChanges(addr, pnd string) (*ppb.GetResponse, error) {
 	return client.Get(ctx, req)
 }
 
-func Commit(addr, pnd string, cuids ...string) (*ppb.SetResponse,error) {
+func Commit(addr, pnd string, cuids ...string) (*ppb.SetResponse, error) {
 	changes := make([]*ppb.SetChange, len(cuids))
 	for i, arg := range cuids {
 		changes[i] = &ppb.SetChange{
@@ -125,7 +126,7 @@ func Commit(addr, pnd string, cuids ...string) (*ppb.SetResponse,error) {
 	return commitConfirm(addr, pnd, changes)
 }
 
-func Confirm(addr, pnd string, cuids ...string) (*ppb.SetResponse,error) {
+func Confirm(addr, pnd string, cuids ...string) (*ppb.SetResponse, error) {
 	changes := make([]*ppb.SetChange, len(cuids))
 	for i, arg := range cuids {
 		changes[i] = &ppb.SetChange{
@@ -136,7 +137,7 @@ func Confirm(addr, pnd string, cuids ...string) (*ppb.SetResponse,error) {
 	return commitConfirm(addr, pnd, changes)
 }
 
-func commitConfirm(addr, pnd string, changes []*ppb.SetChange) (*ppb.SetResponse,error) {
+func commitConfirm(addr, pnd string, changes []*ppb.SetChange) (*ppb.SetResponse, error) {
 	ctx := context.Background()
 	client, err := nbi.PndClient(addr, grpcWithInsecure)
 	if err != nil {
@@ -164,11 +165,11 @@ func AddDevice(addr, username, password, sbi, pnd, deviceAddress, deviceName str
 				Sbi: &spb.SouthboundInterface{
 					Type: spb.Type_OPENCONFIG,
 				},
-				DeviceName:      deviceName,
+				DeviceName: deviceName,
 				TransportOption: &tpb.TransportOption{
-					Address:         addr,
-					Username:        username,
-					Password:        password,
+					Address:  addr,
+					Username: username,
+					Password: password,
 				},
 			},
 		},
@@ -183,7 +184,7 @@ func AddDevice(addr, username, password, sbi, pnd, deviceAddress, deviceName str
 	return nil
 }
 
-func GetDevice(addr, pid, path string, did ...string) (*ppb.GetResponse,error) {
+func GetDevice(addr, pid, path string, did ...string) (*ppb.GetResponse, error) {
 	pndClient, err := nbi.PndClient(addr, grpcWithInsecure)
 	if err != nil {
 		return nil, err
@@ -249,4 +250,4 @@ func sendChangeRequest(addr, pid string, req *ppb.ChangeRequest) (*ppb.SetRespon
 		Pid:           pid,
 	}
 	return pndClient.Set(ctx, r)
-	}
+}
diff --git a/cli/grpc_test.go b/cli/grpc_test.go
index 8a4a76a4c..3e959df94 100644
--- a/cli/grpc_test.go
+++ b/cli/grpc_test.go
@@ -1,19 +1,20 @@
 package cli
 
 import (
+	"context"
+	"net"
+	"reflect"
+	"strconv"
+	"testing"
+	"time"
+
 	pb "code.fbi.h-da.de/cocsn/api/go/gosdn/core"
 	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
 	nbi "code.fbi.h-da.de/cocsn/gosdn/northbound/server"
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus"
-	"context"
 	log "github.com/sirupsen/logrus"
 	"google.golang.org/grpc"
 	"k8s.io/apimachinery/pkg/util/rand"
-	"net"
-	"reflect"
-	"strconv"
-	"testing"
-	"time"
 )
 
 const unreachable = "203.0.113.10:6030"
diff --git a/cmd/getPnd.go b/cmd/getPnd.go
index 0c1f0e0f3..e426d0516 100644
--- a/cmd/getPnd.go
+++ b/cmd/getPnd.go
@@ -41,7 +41,7 @@ import (
 var getCmd = &cobra.Command{
 	Use:   "get",
 	Short: "get one or multiple pnds by uuid or name and print them to stdout",
-	Long: ``,
+	Long:  ``,
 	RunE: func(cmd *cobra.Command, args []string) error {
 		resp, err := cli.GetPnd(apiEndpoint, args...)
 		if err != nil {
diff --git a/cmd/list.go b/cmd/list.go
index b650c07af..ea0a8c13f 100644
--- a/cmd/list.go
+++ b/cmd/list.go
@@ -49,8 +49,8 @@ var listCmd = &cobra.Command{
 		}
 		for _, change := range resp.Change {
 			log.WithFields(log.Fields{
-				"uuid": change.Id,
-				"age": change.Age,
+				"uuid":  change.Id,
+				"age":   change.Age,
 				"state": change.State,
 			}).Infof("")
 		}
diff --git a/controller.go b/controller.go
index e057aaf0b..0f5b4085f 100644
--- a/controller.go
+++ b/controller.go
@@ -1,7 +1,6 @@
 package gosdn
 
 import (
-	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
 	"context"
 	"net"
 	"net/http"
@@ -10,6 +9,8 @@ import (
 	"sync"
 	"time"
 
+	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
+
 	"github.com/spf13/viper"
 	"google.golang.org/grpc"
 
diff --git a/northbound/server/pnd.go b/northbound/server/pnd.go
index c5674f2a5..00bd6e0b4 100644
--- a/northbound/server/pnd.go
+++ b/northbound/server/pnd.go
@@ -236,7 +236,6 @@ func (p pnd) Set(ctx context.Context, request *ppb.SetRequest) (*ppb.SetResponse
 		return nil, err
 	}
 
-
 	ondResp, err := handleSetOnd(pnd, request.Ond)
 	if err != nil {
 		return nil, err
@@ -289,7 +288,7 @@ func handleSetSbi(pnd nucleus.PrincipalNetworkDomain, req []*ppb.SetSbi) (*ppb.S
 }
 
 func handleSetChange(pnd nucleus.PrincipalNetworkDomain, req []*ppb.SetChange) (*ppb.SetResponse, error) {
-	for _,r := range req {
+	for _, r := range req {
 		cuid, err := uuid.Parse(r.Cuid)
 		if err != nil {
 			return nil, err
@@ -317,7 +316,7 @@ func handleSetChange(pnd nucleus.PrincipalNetworkDomain, req []*ppb.SetChange) (
 }
 
 func handleChangeRequest(pnd nucleus.PrincipalNetworkDomain, req []*ppb.ChangeRequest) (*ppb.SetResponse, error) {
-	for _,r := range req {
+	for _, r := range req {
 		did, err := uuid.Parse(r.Id)
 		if err != nil {
 			return nil, err
diff --git a/nucleus/change.go b/nucleus/change.go
index 1e36a8bcf..231f21704 100644
--- a/nucleus/change.go
+++ b/nucleus/change.go
@@ -1,12 +1,13 @@
 package nucleus
 
 import (
-	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
 	"errors"
 	"os"
 	"sync"
 	"time"
 
+	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
+
 	"github.com/google/uuid"
 	"github.com/openconfig/ygot/ygot"
 	log "github.com/sirupsen/logrus"
diff --git a/nucleus/device_test.go b/nucleus/device_test.go
index 6e3cb98f3..ef04e4631 100644
--- a/nucleus/device_test.go
+++ b/nucleus/device_test.go
@@ -1,10 +1,11 @@
 package nucleus
 
 import (
-	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"reflect"
 	"testing"
 
+	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
+
 	"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
 	"github.com/google/uuid"
 	"github.com/openconfig/ygot/ygot"
@@ -91,7 +92,7 @@ func TestNewDevice(t *testing.T) {
 					Password: "test",
 				},
 			},
-			want: nil,
+			want:    nil,
 			wantErr: true,
 		},
 	}
diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go
index ec229e8b8..12d04505e 100644
--- a/nucleus/gnmi_transport.go
+++ b/nucleus/gnmi_transport.go
@@ -1,11 +1,12 @@
 package nucleus
 
 import (
-	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
 	"context"
-	"google.golang.org/grpc"
 	"reflect"
 
+	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
+	"google.golang.org/grpc"
+
 	"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus/types"
diff --git a/nucleus/gnmi_transport_test.go b/nucleus/gnmi_transport_test.go
index aed87d249..c32a269c6 100644
--- a/nucleus/gnmi_transport_test.go
+++ b/nucleus/gnmi_transport_test.go
@@ -1,13 +1,14 @@
 package nucleus
 
 import (
-	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
-	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"context"
 	"errors"
 	"reflect"
 	"testing"
 
+	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
+	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
+
 	"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
 	"code.fbi.h-da.de/cocsn/gosdn/mocks"
 	"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
diff --git a/nucleus/initialise_test.go b/nucleus/initialise_test.go
index bbfe6cc01..d62e06d49 100644
--- a/nucleus/initialise_test.go
+++ b/nucleus/initialise_test.go
@@ -1,11 +1,12 @@
 package nucleus
 
 import (
-	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"context"
 	"os"
 	"testing"
 
+	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
+
 	"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
 	"code.fbi.h-da.de/cocsn/gosdn/mocks"
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto"
@@ -84,15 +85,15 @@ func mockTransport() Gnmi {
 		RespChan: make(chan *gpb.SubscribeResponse),
 		Options:  newGnmiTransportOptions(),
 		client:   &mocks.GNMIClient{},
-		config: gnmiConfig,
+		config:   gnmiConfig,
 	}
 }
 
 func newGnmiTransportOptions() *tpb.TransportOption {
 	return &tpb.TransportOption{
-		Address:         "localhost:13371",
-		Username:        "test",
-		Password:        "test",
+		Address:  "localhost:13371",
+		Username: "test",
+		Password: "test",
 		TransportOption: &tpb.TransportOption_GnmiTransportOption{
 			GnmiTransportOption: &tpb.GnmiTransportOption{},
 		},
diff --git a/nucleus/principalNetworkDomain.go b/nucleus/principalNetworkDomain.go
index dee39d528..216be2b78 100644
--- a/nucleus/principalNetworkDomain.go
+++ b/nucleus/principalNetworkDomain.go
@@ -1,11 +1,12 @@
 package nucleus
 
 import (
+	"context"
+	"reflect"
+
 	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
 	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
-	"context"
-	"reflect"
 
 	"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
 	"github.com/openconfig/ygot/ygot"
diff --git a/nucleus/principalNetworkDomain_test.go b/nucleus/principalNetworkDomain_test.go
index 398679443..8ab5b389d 100644
--- a/nucleus/principalNetworkDomain_test.go
+++ b/nucleus/principalNetworkDomain_test.go
@@ -1,13 +1,14 @@
 package nucleus
 
 import (
-	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
-	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
-	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"errors"
 	"reflect"
 	"testing"
 
+	ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
+	spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
+	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
+
 	"code.fbi.h-da.de/cocsn/gosdn/mocks"
 	"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
 	"github.com/google/uuid"
@@ -556,7 +557,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 		wantErr bool
 	}{
 		{
-			name:   "update",
+			name: "update",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_UPDATE,
@@ -566,7 +567,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: false,
 		},
 		{
-			name:   "replace",
+			name: "replace",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_REPLACE,
@@ -576,7 +577,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: false,
 		},
 		{
-			name:   "delete",
+			name: "delete",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_DELETE,
@@ -585,7 +586,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: false,
 		},
 		{
-			name:   "delete w/args",
+			name: "delete w/args",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_DELETE,
@@ -597,7 +598,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 
 		// Negative test cases
 		{
-			name:   "invalid operation",
+			name: "invalid operation",
 			args: args{
 				uuid:      mdid,
 				operation: 54,
@@ -605,7 +606,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: true,
 		},
 		{
-			name:   "invalid arg count",
+			name: "invalid arg count",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_UPDATE,
@@ -615,7 +616,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: true,
 		},
 		{
-			name:   "invalid arg count - update, no args",
+			name: "invalid arg count - update, no args",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_UPDATE,
@@ -624,7 +625,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: true,
 		},
 		{
-			name:   "invalid arg count - replace, no args",
+			name: "invalid arg count - replace, no args",
 			args: args{
 				uuid:      mdid,
 				operation: ppb.ApiOperation_UPDATE,
@@ -633,7 +634,7 @@ func Test_pndImplementation_ChangeOND(t *testing.T) {
 			wantErr: true,
 		},
 		{
-			name:   "device not found",
+			name: "device not found",
 			args: args{
 				uuid:      did,
 				operation: ppb.ApiOperation_UPDATE,
diff --git a/nucleus/transport.go b/nucleus/transport.go
index c0527b316..dded3c4b2 100644
--- a/nucleus/transport.go
+++ b/nucleus/transport.go
@@ -1,9 +1,10 @@
 package nucleus
 
 import (
+	"context"
+
 	tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
 	"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
-	"context"
 
 	"github.com/openconfig/ygot/ytypes"
 )
-- 
GitLab