> golang-api-server
Standards for building HTTP services, REST APIs, and middleware in Golang. Use when building Go HTTP servers, REST APIs, or custom middleware. (triggers: cmd/server/*.go, internal/adapter/handler/**, http server, rest api, gin, echo, middleware)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/golang-api-server?format=md"Golang API Server Standards
Priority: P0 (CRITICAL)
Router Selection
- Standard Lib (
net/http): Use for simple services or when zero deps is required. Usehttp.ServeMux(Go 1.22+ has decent routing). - Echo (
labstack/echo): Recommended for production REST APIs. Excellent middleware support, binding, and error handling. - Gin (
gin-gonic/gin): High performance alternative.
Guidelines
- Graceful Shutdown: MUST implement graceful shutdown to handle in-flight requests on termination (SIGINT/SIGTERM).
- DTOs: Separate Domain structs from API Request/Response structs. Map between them.
- Middleware: Use middleware for cross-cutting concerns (Logging, Recovery, CORS, Auth, Tracing).
- Health Checks: Always include
/healthand/readyendpoints. - Content-Type: Enforce
application/jsonfor REST APIs.
Middleware Pattern
- Standard:
func(next http.Handler) http.Handler - Echo implementation:
func(next echo.HandlerFunc) echo.HandlerFunc
Anti-Patterns
- Business Logic in Handlers: Handlers should only parse request -> call service -> format response.
- Global Router: Don't use global router variables. Pass router instance.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)