mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-07-26 09:58:40 +00:00
syntax cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user