From b41a470b78ca7a8e3a32654647cffeb36b7f91cc Mon Sep 17 00:00:00 2001 From: John Westcott IV Date: Tue, 9 Nov 2021 15:15:08 -0500 Subject: [PATCH] Fixing linting issues --- pkg/netceptor/netceptor.go | 22 ++++++++++++---------- pkg/netceptor/netceptor_test.go | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/netceptor/netceptor.go b/pkg/netceptor/netceptor.go index d4b50f5e1..51f8ff376 100644 --- a/pkg/netceptor/netceptor.go +++ b/pkg/netceptor/netceptor.go @@ -221,7 +221,8 @@ const ( // ConnTypeStreamTLS indicates the service listens on a packetconn connection, with a user-defined TLS. ConnTypeStreamTLS = 2 ) -var ConnTypeStrings = [...]string {"Datagram", "Stream", "StreamTLS"} + +var ConnTypeStrings = [...]string{"Datagram", "Stream", "StreamTLS"} // WorkCommand tracks available work types and whether they verify work submissions. type WorkCommand struct { @@ -232,13 +233,13 @@ type WorkCommand struct { // ServiceAdvertisement is the data associated with a service advertisement. type ServiceAdvertisement struct { - NodeID string - Service string - Time time.Time - ConnType byte - ConnTypeLabel string - Tags map[string]string - WorkCommands []WorkCommand + NodeID string + Service string + Time time.Time + ConnType byte + ConnTypeLabel string + Tags map[string]string + WorkCommands []WorkCommand } // serviceAdvertisementFull is the whole message from the network. @@ -435,12 +436,13 @@ func (s *Netceptor) MaxConnectionIdleTime() time.Duration { return s.maxConnectionIdleTime } -// Convert the connection type to a string +// Convert the connection type to a string. func (s *Netceptor) GetConnectionTypeAsString(connectionType byte) string { - // A byte can't be < 0 so we don't need to check the lower bounds + // A byte can't be < 0 so we don't need to check the lower bounds if connectionType < byte(len(ConnTypeStrings)) { return ConnTypeStrings[connectionType] } + return "Unknown" } diff --git a/pkg/netceptor/netceptor_test.go b/pkg/netceptor/netceptor_test.go index 6f0d34d30..20d20dc57 100644 --- a/pkg/netceptor/netceptor_test.go +++ b/pkg/netceptor/netceptor_test.go @@ -798,7 +798,7 @@ func TestConnTypeString(t *testing.T) { if ConnTypeStrings[ConnTypeDatagram] != n1.GetConnectionTypeAsString(0) { t.Fatal("Datagram should be the first entry in ConnTypeStrings") } - if "Unknown" != n1.GetConnectionTypeAsString(254) { + if n1.GetConnectionTypeAsString(254) != "Unknown" { t.Fatal("Either we now have 254 ConnTypes or GetConnectionTypeAsString did not properly return Unknown") } // Shutdown the network