Go project structure -- cmd/internal layout, handler/service/repository layers, Makefile, config from environment, domain error types, test placement, dependency injection
90
84%
Does it follow best practices?
Impact
100%
1.02xAverage score across 5 eval scenarios
Passed
No known issues
A platform team needs a simple task queue service in Go. The service accepts tasks via a REST API (with a type, payload, and priority), stores them in a database, and exposes endpoints for workers to claim and complete tasks. This is an internal service -- no external integrations needed.
Task types include "email", "notification", and "report". Tasks have statuses: pending, processing, completed, failed. Workers claim the highest-priority pending task and mark it as processing, then later report completion or failure.
The team wants this service to be a reference implementation of Go project structure best practices for other teams to follow.
Produce a complete project structure with:
go.mod with module pathcmd/taskqueue/main.go -- entry point wiring DB -> repositories -> services -> handler, start server with config-driven timeouts, graceful shutdowninternal/config/config.go -- Config struct with PORT, DATABASE_URL, MAX_RETRIES, WORKER_TIMEOUT_SECONDS from environmentinternal/domain/models.go -- Task (ID, Type, Payload as json.RawMessage or string, Priority, Status, RetryCount, CreatedAt, UpdatedAt, ClaimedAt), TaskStatus constants, TaskType constants, CreateTaskRequest, ClaimTaskResponseinternal/domain/errors.go -- AppError, NotFoundError, ValidationError, ConflictError (task already claimed)internal/handler/ -- Handler struct, route registration, endpoints: POST /tasks (create), GET /tasks (list with optional status filter), GET /tasks/{id}, POST /tasks/claim (claim next), PUT /tasks/{id}/complete, PUT /tasks/{id}/fail. Response helpers.internal/service/tasks.go -- TaskService with validation logic (valid type, positive priority), claim logic (find highest priority pending task), completion/failure logic. Defines TaskRepository interface.internal/repository/tasks.go -- SQL TaskRepoMakefile with build, run, test, test-coverage, lint, fmt, vet, tidy, clean targets.gitignore for Gointernal/service/tasks_test.go with table-driven tests covering: create with invalid type, create with zero/negative priority, claim when no tasks available, complete a non-processing taskinternal/handler/handler_test.go or internal/handler/tasks_test.go with at least one HTTP handler test