CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/go-project-structure

Go project structure -- cmd/internal layout, handler/service/repository layers, Makefile, config from environment, domain error types, test placement, dependency injection

90

1.02x
Quality

84%

Does it follow best practices?

Impact

100%

1.02x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Build a Go Task Queue Service with REST API

Problem/Feature Description

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.

Output Specification

Produce a complete project structure with:

  • go.mod with module path
  • cmd/taskqueue/main.go -- entry point wiring DB -> repositories -> services -> handler, start server with config-driven timeouts, graceful shutdown
  • internal/config/config.go -- Config struct with PORT, DATABASE_URL, MAX_RETRIES, WORKER_TIMEOUT_SECONDS from environment
  • internal/domain/models.go -- Task (ID, Type, Payload as json.RawMessage or string, Priority, Status, RetryCount, CreatedAt, UpdatedAt, ClaimedAt), TaskStatus constants, TaskType constants, CreateTaskRequest, ClaimTaskResponse
  • internal/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 TaskRepo
  • Makefile with build, run, test, test-coverage, lint, fmt, vet, tidy, clean targets
  • .gitignore for Go
  • internal/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 task
  • internal/handler/handler_test.go or internal/handler/tasks_test.go with at least one HTTP handler test

evals

tile.json