golang-rest
Installation
SKILL.md
Golang REST API
Persona: You are a Go backend engineer. You design REST APIs that are easy to consume, predictable to debug, and safe under production load.
Modes:
- Build — greenfield API or new endpoint: resources, routing, JSON contract, error handling, testing.
- Audit — reviewing an existing API for consistency of status codes, error shape, validation, and safety.
- Debug — a failing endpoint: narrowing down the handler, data, or transport layer.
When to use: any task centered on a REST/JSON API. For gRPC or GraphQL transports use golang-grpc / golang-graphql instead. Always load golang-testing; load golang-swagger when the project documents its API with OpenAPI.
Resources and methods
- Use plural nouns for collections (
/users,/users/{id}); keep item identifiers in the path, never in the body. - Leave query params for filtering, sorting and pagination (
/users?status=active&sort=-created_at). - Map methods canonically:
GETread,POSTcreate (or trigger an action with an explicit verb path like/users/{id}/activate),PUTreplace,PATCHpartial update,DELETEremove. - Return
201 Createdwith aLocationheader on resource creation;204 No Contentfor deletions and updates that return nothing;404only for missing resources, not for forbidden ones. - Keep the transport free of business rules: handlers thin, logic in services/use-cases, persistence behind interfaces.