syntax cleanup

This commit is contained in:
Joel Wetzell
2026-07-09 22:22:22 -05:00
parent 777f9c43de
commit b86ca20592
9 changed files with 26 additions and 13 deletions
+2 -1
View File
@@ -30,7 +30,8 @@ func RegisterModule(mod ModuleRegistration) {
moduleRegistryMu.Lock() moduleRegistryMu.Lock()
defer moduleRegistryMu.Unlock() 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)) panic(fmt.Sprintf("module already registered: %s", mod.Type))
} }
moduleRegistry[string(mod.Type)] = mod moduleRegistry[string(mod.Type)] = mod
+2 -1
View File
@@ -75,7 +75,8 @@ func (pc *PSNClient) Start(ctx context.Context, inputHandler common.InputHandler
pc.connMu.Unlock() pc.connMu.Unlock()
if err != nil { if err != nil {
//NOTE(jwetzell) we hit deadline //NOTE(jwetzell) we hit deadline
if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() { opErr, ok := err.(*net.OpError)
if ok && opErr.Timeout() {
continue continue
} }
return err return err
+2 -1
View File
@@ -126,7 +126,8 @@ CONNECT_RETRY:
byteCount, err := tc.conn.Read(buffer) byteCount, err := tc.conn.Read(buffer)
if err != nil { if err != nil {
if opErr, ok := err.(*net.OpError); ok { opErr, ok := err.(*net.OpError)
if ok {
//NOTE(jwetzell) we hit deadline //NOTE(jwetzell) we hit deadline
if opErr.Timeout() { if opErr.Timeout() {
continue continue
+2 -1
View File
@@ -141,7 +141,8 @@ func (ts *TCPServer) handleClient(client *net.TCPConn) {
client.SetDeadline(time.Now().Add(time.Millisecond * 200)) client.SetDeadline(time.Now().Add(time.Millisecond * 200))
byteCount, err := client.Read(buffer) byteCount, err := client.Read(buffer)
if err != nil { if err != nil {
if opErr, ok := err.(*net.OpError); ok { opErr, ok := err.(*net.OpError)
if ok {
//NOTE(jwetzell) we hit deadline //NOTE(jwetzell) we hit deadline
if opErr.Timeout() { if opErr.Timeout() {
continue continue
+6 -3
View File
@@ -11,7 +11,8 @@ import (
func TestModuleBadRegistrationNoType(t *testing.T) { func TestModuleBadRegistrationNoType(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { r := recover()
if r == nil {
t.Fatalf("module registration should have panicked but did not") t.Fatalf("module registration should have panicked but did not")
} }
}() }()
@@ -26,7 +27,8 @@ func TestModuleBadRegistrationNoType(t *testing.T) {
func TestModuleBadRegistrationNoNew(t *testing.T) { func TestModuleBadRegistrationNoNew(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { r := recover()
if r == nil {
t.Fatalf("processor registration should have panicked but did not") t.Fatalf("processor registration should have panicked but did not")
} }
}() }()
@@ -39,7 +41,8 @@ func TestModuleBadRegistrationNoNew(t *testing.T) {
func TestModuleBadRegistrationExistingType(t *testing.T) { func TestModuleBadRegistrationExistingType(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { r := recover()
if r == nil {
t.Fatalf("processor registration should have panicked but did not") t.Fatalf("processor registration should have panicked but did not")
} }
}() }()
+2 -1
View File
@@ -104,7 +104,8 @@ func (um *UDPMulticast) Start(ctx context.Context, inputHandler common.InputHand
break break
} }
//NOTE(jwetzell) we hit deadline //NOTE(jwetzell) we hit deadline
if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() { opErr, ok := err.(*net.OpError)
if ok && opErr.Timeout() {
continue continue
} }
return err return err
+2 -1
View File
@@ -123,7 +123,8 @@ func (us *UDPServer) Start(ctx context.Context, inputHandler common.InputHandler
numBytes, _, err := listener.ReadFromUDP(buffer) numBytes, _, err := listener.ReadFromUDP(buffer)
if err != nil { if err != nil {
//NOTE(jwetzell) we hit deadline //NOTE(jwetzell) we hit deadline
if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() { opErr, ok := err.(*net.OpError)
if ok && opErr.Timeout() {
continue continue
} }
break break
+2 -1
View File
@@ -35,7 +35,8 @@ func RegisterProcessor(processor ProcessorRegistration) {
processorRegistryMu.Lock() processorRegistryMu.Lock()
defer processorRegistryMu.Unlock() 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)) panic(fmt.Sprintf("processor already registered: %s", processor.Type))
} }
processorRegistry[string(processor.Type)] = processor processorRegistry[string(processor.Type)] = processor
+6 -3
View File
@@ -10,7 +10,8 @@ import (
func TestProcessorBadRegistrationNoType(t *testing.T) { func TestProcessorBadRegistrationNoType(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { r := recover()
if r == nil {
t.Fatalf("processor registration should have panicked but did not") t.Fatalf("processor registration should have panicked but did not")
} }
}() }()
@@ -25,7 +26,8 @@ func TestProcessorBadRegistrationNoType(t *testing.T) {
func TestProcessorBadRegistrationNoNew(t *testing.T) { func TestProcessorBadRegistrationNoNew(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { r := recover()
if r == nil {
t.Fatalf("processor registration should have panicked but did not") t.Fatalf("processor registration should have panicked but did not")
} }
}() }()
@@ -38,7 +40,8 @@ func TestProcessorBadRegistrationNoNew(t *testing.T) {
func TestProcessorBadRegistrationExistingType(t *testing.T) { func TestProcessorBadRegistrationExistingType(t *testing.T) {
defer func() { defer func() {
if r := recover(); r == nil { r := recover()
if r == nil {
t.Fatalf("processor registration should have panicked but did not") t.Fatalf("processor registration should have panicked but did not")
} }
}() }()