mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-05-13 21:14:16 +00:00
chore: go fix
This commit is contained in:
@@ -31,7 +31,7 @@ func init() {
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"dsn": {
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
},
|
||||
},
|
||||
Required: []string{"dsn"},
|
||||
|
||||
@@ -68,7 +68,7 @@ func (rc *RedisClient) Type() string {
|
||||
return rc.config.Type
|
||||
}
|
||||
|
||||
func (rc *RedisClient) Printf(ctx context.Context, format string, v ...interface{}) {
|
||||
func (rc *RedisClient) Printf(ctx context.Context, format string, v ...any) {
|
||||
msg := fmt.Sprintf(format, v...)
|
||||
rc.logger.Debug(msg)
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ func init() {
|
||||
"separator": {
|
||||
Title: "DTMF Separator",
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MaxLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
MaxLength: new(1),
|
||||
},
|
||||
},
|
||||
Required: []string{"separator"},
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -24,7 +25,7 @@ type TCPServer struct {
|
||||
Framer framer.Framer
|
||||
ctx context.Context
|
||||
router common.RouteIO
|
||||
quit chan interface{}
|
||||
quit chan any
|
||||
wg sync.WaitGroup
|
||||
connections []*net.TCPConn
|
||||
connectionsMu sync.RWMutex
|
||||
@@ -90,7 +91,7 @@ func init() {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &TCPServer{Framer: framer, Addr: addr, config: moduleConfig, quit: make(chan interface{}), logger: CreateLogger(moduleConfig)}, nil
|
||||
return &TCPServer{Framer: framer, Addr: addr, config: moduleConfig, quit: make(chan any), logger: CreateLogger(moduleConfig)}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -213,11 +214,9 @@ AcceptLoop:
|
||||
ts.logger.Debug("problem with listener", "error", err)
|
||||
}
|
||||
} else {
|
||||
ts.wg.Add(1)
|
||||
go func() {
|
||||
ts.wg.Go(func() {
|
||||
ts.handleClient(conn)
|
||||
ts.wg.Done()
|
||||
}()
|
||||
})
|
||||
}
|
||||
}
|
||||
ts.wg.Done()
|
||||
@@ -232,20 +231,20 @@ func (ts *TCPServer) Output(ctx context.Context, payload any) error {
|
||||
return errors.New("net.tcp.server is only able to output bytes")
|
||||
}
|
||||
ts.connectionsMu.Lock()
|
||||
errorString := ""
|
||||
var errorString strings.Builder
|
||||
|
||||
for _, connection := range ts.connections {
|
||||
_, err := connection.Write(payloadBytes)
|
||||
if err != nil {
|
||||
errorString += fmt.Sprintf("%s\n", err.Error())
|
||||
errorString.WriteString(fmt.Sprintf("%s\n", err.Error()))
|
||||
}
|
||||
}
|
||||
ts.connectionsMu.Unlock()
|
||||
|
||||
if errorString == "" {
|
||||
if errorString.String() == "" {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("net.tcp.server error during output: %s", errorString)
|
||||
return fmt.Errorf("net.tcp.server error during output: %s", errorString.String())
|
||||
}
|
||||
|
||||
func (ts *TCPServer) Stop() {
|
||||
|
||||
@@ -68,10 +68,10 @@ func (dq *DbQuery) Process(ctx context.Context, wrappedPayload common.WrappedPay
|
||||
results := make([]map[string]any, 0)
|
||||
|
||||
for rows.Next() {
|
||||
columnValues := make([]interface{}, len(columns))
|
||||
columnValues := make([]any, len(columns))
|
||||
|
||||
for i := range columnValues {
|
||||
columnValues[i] = new(interface{})
|
||||
columnValues[i] = new(any)
|
||||
}
|
||||
|
||||
if err := rows.Scan(columnValues...); err != nil {
|
||||
@@ -81,7 +81,7 @@ func (dq *DbQuery) Process(ctx context.Context, wrappedPayload common.WrappedPay
|
||||
|
||||
rowMap := make(map[string]any)
|
||||
for i, colName := range columns {
|
||||
value := *columnValues[i].(*interface{})
|
||||
value := *columnValues[i].(*any)
|
||||
rowMap[colName] = value
|
||||
}
|
||||
results = append(results, rowMap)
|
||||
|
||||
@@ -61,12 +61,12 @@ func (sj *ScriptJS) Process(ctx context.Context, wrappedPayload common.WrappedPa
|
||||
outputObject, ok := output.(*quickjs.Object)
|
||||
|
||||
if ok {
|
||||
var outputSlice []interface{}
|
||||
var outputSlice []any
|
||||
|
||||
err = outputObject.Into(&outputSlice)
|
||||
|
||||
if err != nil {
|
||||
var outputMap map[string]interface{}
|
||||
var outputMap map[string]any
|
||||
err = outputObject.Into(&outputMap)
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and string arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -69,7 +69,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and mixed args",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"arg1", "42", "3.14"},
|
||||
"args": []any{"arg1", "42", "3.14"},
|
||||
"types": "sif",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -86,7 +86,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and int64 arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"42"},
|
||||
"args": []any{"42"},
|
||||
"types": "h",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -96,7 +96,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and double arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"42"},
|
||||
"args": []any{"42"},
|
||||
"types": "d",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -106,7 +106,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and true arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{""},
|
||||
"args": []any{""},
|
||||
"types": "T",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -116,7 +116,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and false arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{""},
|
||||
"args": []any{""},
|
||||
"types": "F",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -126,7 +126,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and nil arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{""},
|
||||
"args": []any{""},
|
||||
"types": "N",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -136,7 +136,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "blob arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"deadbeef"},
|
||||
"args": []any{"deadbeef"},
|
||||
"types": "b",
|
||||
},
|
||||
payload: "",
|
||||
@@ -228,7 +228,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "args without types parameter",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create types error: not found",
|
||||
@@ -237,7 +237,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "args and types length mismatch",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1", "arg2"},
|
||||
"args": []any{"arg1", "arg2"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -247,7 +247,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "non-string arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1", 123},
|
||||
"args": []any{"arg1", 123},
|
||||
"types": "ss",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -257,7 +257,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "bad arg template",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{"},
|
||||
"args": []any{"{{"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -267,7 +267,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "non-string types parameter",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
"types": 123,
|
||||
},
|
||||
payload: "test",
|
||||
@@ -277,7 +277,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "invalid type in types parameter",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
"types": "x",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -311,7 +311,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "address template with missing field",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.missing}}"},
|
||||
"args": []any{"{{.missing}}"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -321,7 +321,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for int arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "i",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -331,7 +331,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for float arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "f",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -341,7 +341,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for blob arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "b",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -351,7 +351,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for int64 arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "h",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -361,7 +361,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for double arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "d",
|
||||
},
|
||||
payload: "test",
|
||||
|
||||
@@ -145,7 +145,7 @@ func TestGoodScriptJS(t *testing.T) {
|
||||
"program": "",
|
||||
},
|
||||
payload: []byte("test"),
|
||||
expected: []interface{}{float64('t'), float64('e'), float64('s'), float64('t')},
|
||||
expected: []any{float64('t'), float64('e'), float64('s'), float64('t')},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func GetModulesSchema() *jsonschema.Schema {
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"id": {
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
},
|
||||
"type": {
|
||||
Const: jsonschema.Ptr[any](mod.Type),
|
||||
|
||||
@@ -17,7 +17,7 @@ var RoutesConfigSchema = jsonschema.Schema{
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"input": {
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
},
|
||||
"processors": {
|
||||
Ref: "https://showbridge.io/processors.schema.json",
|
||||
|
||||
Reference in New Issue
Block a user