fix: resolve all linting and formatting issues

- Fix error return value checks (errcheck)
- Fix unused parameters by using underscore prefix
- Add missing package comments to all packages
- Fix context key type issue in middleware (use typed contextKey)
- Replace deprecated trace.NewNoopTracerProvider with noop.NewTracerProvider
- Fix embedded field selector in database client
- Remove trailing whitespace
- Remove revive linter (as requested) to avoid stuttering warnings for public API interfaces

All linting and formatting checks now pass.
This commit is contained in:
2025-11-05 20:48:59 +01:00
parent 926f3f927e
commit 52d48590ae
21 changed files with 57 additions and 68 deletions

View File

@@ -1,3 +1,4 @@
// Package server provides HTTP middleware functions for request processing.
package server
import (
@@ -6,15 +7,17 @@ import (
"runtime"
"time"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"git.dcentral.systems/toolz/goplt/pkg/errorbus"
"git.dcentral.systems/toolz/goplt/pkg/logger"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
type contextKey string
const (
requestIDKey = "request_id"
userIDKey = "user_id"
requestIDKey contextKey = "request_id"
userIDKey contextKey = "user_id"
)
// RequestIDMiddleware generates a unique request ID for each request.
@@ -25,7 +28,7 @@ func RequestIDMiddleware() gin.HandlerFunc {
requestID = uuid.New().String()
}
c.Set(requestIDKey, requestID)
c.Set(string(requestIDKey), requestID)
c.Header("X-Request-ID", requestID)
c.Next()
}
@@ -45,7 +48,7 @@ func LoggingMiddleware(log logger.Logger) gin.HandlerFunc {
duration := time.Since(start)
// Get request ID from context
requestID, _ := c.Get(requestIDKey)
requestID, _ := c.Get(string(requestIDKey))
requestIDStr := ""
if id, ok := requestID.(string); ok {
requestIDStr = id
@@ -74,8 +77,8 @@ func PanicRecoveryMiddleware(errorBus errorbus.ErrorPublisher) gin.HandlerFunc {
stack = stack[:n]
// Get request ID from context
requestID, _ := c.Get(requestIDKey)
ctx := context.WithValue(context.Background(), "request_id", requestID)
requestID, _ := c.Get(string(requestIDKey))
ctx := context.WithValue(context.Background(), requestIDKey, requestID)
// Create error
var panicErr error
@@ -138,4 +141,3 @@ func TimeoutMiddleware(timeout time.Duration) gin.HandlerFunc {
c.Next()
}
}