Every backend service MUST use structured logging — pino/structlog/slog, JSON format, request IDs, proper log levels. console.log is never acceptable.
88
85%
Does it follow best practices?
Impact
97%
3.03xAverage score across 4 eval scenarios
Passed
No known issues
A retail company needs a Go HTTP service that receives inventory update webhooks from their warehouse management system. When the warehouse ships items, adjusts stock, or receives new inventory, it sends a webhook to this service. The service validates the webhook, updates an in-memory inventory map, and returns appropriate status codes.
The service needs these endpoints:
POST /webhooks/inventory — Receive an inventory webhook. The request body contains: event_type (one of: "stock_received", "stock_shipped", "stock_adjusted"), sku, quantity (integer, positive for additions, negative for removals), warehouse_id, and timestamp. Validate that all required fields are present and quantity is non-zero. If the SKU doesn't exist, create it. If a shipment would bring stock below zero, reject with 409 Conflict.GET /inventory/:sku — Get current stock level for a SKU. Returns 404 if SKU not found.GET /inventory — List all SKUs and their current stock levels.GET /health — Health check endpoint, returns 200 OK.Use Go's standard library net/http. The service will run in a Kubernetes cluster with Fluent Bit collecting stdout for Elasticsearch.
Produce:
output/go.mod — Module file with dependenciesoutput/main.go — Server setup and entry pointoutput/handlers.go — HTTP handler functionsoutput/middleware.go — Any middleware neededComplete Go code, no placeholders or TODO comments.