Golang api server
Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/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)From its SKILL.md
npx -y skills add ComeOnOliver/skillshub --skill golang-api-serverAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.7 KB, 319 tokens by cl100k_base, as published. Nobody here has run it
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
- No business logic in handlers: Parse request → call service → format response only.
- No global router vars: Pass router instance via constructor or DI.
- No missing graceful shutdown: Always handle SIGTERM to drain in-flight requests.
References
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.