Skip to content

Commit

Permalink
Fixing linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
john-westcott-iv committed Nov 18, 2021
1 parent 75317b1 commit 9273039
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions pkg/netceptor/netceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/netceptor/netceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9273039

Please sign in to comment.