diff --git a/internal/module/module.go b/internal/module/module.go index 35c2761..d02b1bb 100644 --- a/internal/module/module.go +++ b/internal/module/module.go @@ -30,7 +30,8 @@ func RegisterModule(mod ModuleRegistration) { moduleRegistryMu.Lock() defer moduleRegistryMu.Unlock() - if _, ok := moduleRegistry[string(mod.Type)]; ok { + _, exists := moduleRegistry[string(mod.Type)] + if exists { panic(fmt.Sprintf("module already registered: %s", mod.Type)) } moduleRegistry[string(mod.Type)] = mod diff --git a/internal/module/psn-client.go b/internal/module/psn-client.go index cf389bb..d533566 100644 --- a/internal/module/psn-client.go +++ b/internal/module/psn-client.go @@ -75,7 +75,8 @@ func (pc *PSNClient) Start(ctx context.Context, inputHandler common.InputHandler pc.connMu.Unlock() if err != nil { //NOTE(jwetzell) we hit deadline - if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() { + opErr, ok := err.(*net.OpError) + if ok && opErr.Timeout() { continue } return err diff --git a/internal/module/tcp-client.go b/internal/module/tcp-client.go index 07b25df..df55608 100644 --- a/internal/module/tcp-client.go +++ b/internal/module/tcp-client.go @@ -126,7 +126,8 @@ CONNECT_RETRY: byteCount, err := tc.conn.Read(buffer) if err != nil { - if opErr, ok := err.(*net.OpError); ok { + opErr, ok := err.(*net.OpError) + if ok { //NOTE(jwetzell) we hit deadline if opErr.Timeout() { continue diff --git a/internal/module/tcp-server.go b/internal/module/tcp-server.go index 59e2091..56fa258 100644 --- a/internal/module/tcp-server.go +++ b/internal/module/tcp-server.go @@ -141,7 +141,8 @@ func (ts *TCPServer) handleClient(client *net.TCPConn) { client.SetDeadline(time.Now().Add(time.Millisecond * 200)) byteCount, err := client.Read(buffer) if err != nil { - if opErr, ok := err.(*net.OpError); ok { + opErr, ok := err.(*net.OpError) + if ok { //NOTE(jwetzell) we hit deadline if opErr.Timeout() { continue diff --git a/internal/module/test/module_test.go b/internal/module/test/module_test.go index c083ef1..ca3758e 100644 --- a/internal/module/test/module_test.go +++ b/internal/module/test/module_test.go @@ -11,7 +11,8 @@ import ( func TestModuleBadRegistrationNoType(t *testing.T) { defer func() { - if r := recover(); r == nil { + r := recover() + if r == nil { t.Fatalf("module registration should have panicked but did not") } }() @@ -26,7 +27,8 @@ func TestModuleBadRegistrationNoType(t *testing.T) { func TestModuleBadRegistrationNoNew(t *testing.T) { defer func() { - if r := recover(); r == nil { + r := recover() + if r == nil { t.Fatalf("processor registration should have panicked but did not") } }() @@ -39,7 +41,8 @@ func TestModuleBadRegistrationNoNew(t *testing.T) { func TestModuleBadRegistrationExistingType(t *testing.T) { defer func() { - if r := recover(); r == nil { + r := recover() + if r == nil { t.Fatalf("processor registration should have panicked but did not") } }() diff --git a/internal/module/udp-multicast.go b/internal/module/udp-multicast.go index bdeb7d1..9f67274 100644 --- a/internal/module/udp-multicast.go +++ b/internal/module/udp-multicast.go @@ -104,7 +104,8 @@ func (um *UDPMulticast) Start(ctx context.Context, inputHandler common.InputHand break } //NOTE(jwetzell) we hit deadline - if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() { + opErr, ok := err.(*net.OpError) + if ok && opErr.Timeout() { continue } return err diff --git a/internal/module/udp-server.go b/internal/module/udp-server.go index d54d554..4234815 100644 --- a/internal/module/udp-server.go +++ b/internal/module/udp-server.go @@ -123,7 +123,8 @@ func (us *UDPServer) Start(ctx context.Context, inputHandler common.InputHandler numBytes, _, err := listener.ReadFromUDP(buffer) if err != nil { //NOTE(jwetzell) we hit deadline - if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() { + opErr, ok := err.(*net.OpError) + if ok && opErr.Timeout() { continue } break diff --git a/internal/processor/processor.go b/internal/processor/processor.go index 73d7ca0..4799f1f 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -35,7 +35,8 @@ func RegisterProcessor(processor ProcessorRegistration) { processorRegistryMu.Lock() defer processorRegistryMu.Unlock() - if _, ok := processorRegistry[string(processor.Type)]; ok { + _, exists := processorRegistry[string(processor.Type)] + if exists { panic(fmt.Sprintf("processor already registered: %s", processor.Type)) } processorRegistry[string(processor.Type)] = processor diff --git a/internal/processor/test/processor_test.go b/internal/processor/test/processor_test.go index 5a383cc..0aa0fb7 100644 --- a/internal/processor/test/processor_test.go +++ b/internal/processor/test/processor_test.go @@ -10,7 +10,8 @@ import ( func TestProcessorBadRegistrationNoType(t *testing.T) { defer func() { - if r := recover(); r == nil { + r := recover() + if r == nil { t.Fatalf("processor registration should have panicked but did not") } }() @@ -25,7 +26,8 @@ func TestProcessorBadRegistrationNoType(t *testing.T) { func TestProcessorBadRegistrationNoNew(t *testing.T) { defer func() { - if r := recover(); r == nil { + r := recover() + if r == nil { t.Fatalf("processor registration should have panicked but did not") } }() @@ -38,7 +40,8 @@ func TestProcessorBadRegistrationNoNew(t *testing.T) { func TestProcessorBadRegistrationExistingType(t *testing.T) { defer func() { - if r := recover(); r == nil { + r := recover() + if r == nil { t.Fatalf("processor registration should have panicked but did not") } }()