diff --git a/gjson/encode.go b/gjson/encode.go index 70804c8..1434e67 100644 --- a/gjson/encode.go +++ b/gjson/encode.go @@ -23,11 +23,11 @@ func encodeLuaValue(L *glua.LState, value glua.LValue, config *Config, depth int return "false", nil case glua.LTNumber: - num := float64(value.(glua.LNumber)) + num := float64(value.(glua.LNumber)) //nolint:errcheck // switch case guarantees type return formatNumber(num, config.encodeNumberPrecision), nil case glua.LTString: - str := string(value.(glua.LString)) + str := string(value.(glua.LString)) //nolint:errcheck // switch case guarantees type // Use go-json for proper string escaping result, err := json.Marshal(str) if err != nil { @@ -36,7 +36,7 @@ func encodeLuaValue(L *glua.LState, value glua.LValue, config *Config, depth int return string(result), nil case glua.LTTable: - return encodeTable(L, value.(*glua.LTable), config, depth) + return encodeTable(L, value.(*glua.LTable), config, depth) //nolint:errcheck // switch case guarantees type case glua.LTUserData: if isNull(value) { @@ -82,7 +82,7 @@ func checkArrayType(tbl *glua.LTable, config *Config) (bool, int, int) { count := 0 hasStringKey := false - tbl.ForEach(func(key, value glua.LValue) { + tbl.ForEach(func(key, _ glua.LValue) { switch k := key.(type) { case glua.LNumber: // Protect against integer overflow - only accept positive integers within int range diff --git a/internal/benchmark/tools/tools.go b/internal/benchmark/tools/tools.go index 0f07639..79be0cf 100644 --- a/internal/benchmark/tools/tools.go +++ b/internal/benchmark/tools/tools.go @@ -61,10 +61,14 @@ func SimpleMockBackend(statusCode int, responseBody []byte) (string, func()) { ctx.SetBody(responseBody) } - go fasthttp.Serve(ln, handler) + go func() { + if serveErr := fasthttp.Serve(ln, handler); serveErr != nil { + panic(serveErr) + } + }() return ln.Addr().String(), func() { - ln.Close() + _ = ln.Close() } } @@ -87,10 +91,14 @@ func ErrorMockBackend(errorRate float64, errorBody []byte) (string, func()) { ctx.SetBody([]byte("OK")) } - go fasthttp.Serve(ln, handler) + go func() { + if serveErr := fasthttp.Serve(ln, handler); serveErr != nil { + panic(serveErr) + } + }() return ln.Addr().String(), func() { - ln.Close() + _ = ln.Close() } } @@ -107,10 +115,14 @@ func DelayedMockBackend(delay time.Duration, statusCode int, responseBody []byte ctx.SetBody(responseBody) } - go fasthttp.Serve(ln, handler) + go func() { + if serveErr := fasthttp.Serve(ln, handler); serveErr != nil { + panic(serveErr) + } + }() return ln.Addr().String(), func() { - ln.Close() + _ = ln.Close() } } @@ -154,9 +166,13 @@ func StartMockFasthttpBackend(config MockBackendConfig) (string, func()) { } } - go fasthttp.Serve(ln, handler) + go func() { + if serveErr := fasthttp.Serve(ln, handler); serveErr != nil { + panic(serveErr) + } + }() return ln.Addr().String(), func() { - ln.Close() + _ = ln.Close() } } diff --git a/internal/server/server.go b/internal/server/server.go index 7d5e98c..81c8a80 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -649,9 +649,9 @@ func (s *Server) startMultiServerMode() error { // 注册状态监控端点(仅默认服务器) if serverCfg.Default && s.config.Monitoring.Status.Enabled { - statusHandler, err := NewStatusHandler(s, &s.config.Monitoring.Status) - if err != nil { - logging.Error().Msg("Failed to create status handler: " + err.Error()) + statusHandler, statusErr := NewStatusHandler(s, &s.config.Monitoring.Status) + if statusErr != nil { + logging.Error().Msg("Failed to create status handler: " + statusErr.Error()) } else { router.GET(statusHandler.Path(), statusHandler.ServeHTTP) } @@ -659,9 +659,9 @@ func (s *Server) startMultiServerMode() error { // 注册 pprof 性能分析端点(仅默认服务器) if serverCfg.Default && s.config.Monitoring.Pprof.Enabled { - pprofHandler, err := NewPprofHandler(&s.config.Monitoring.Pprof) - if err != nil { - logging.Error().Msg("Failed to create pprof handler: " + err.Error()) + pprofHandler, pprofErr := NewPprofHandler(&s.config.Monitoring.Pprof) + if pprofErr != nil { + logging.Error().Msg("Failed to create pprof handler: " + pprofErr.Error()) } else { router.GET(pprofHandler.Path(), pprofHandler.ServeHTTP) router.GET(pprofHandler.Path()+"/{profile:*}", pprofHandler.ServeHTTP)