go-servemux-rest-api-cursorrules-prompt-file — Cursor rule
A Cursor rule that points the assistant at Go REST APIs built with net/http and the ServeMux router from Go 1.22.
.cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdcWhat go-servemux-rest-api-cursorrules-prompt-file does
The rule casts the assistant as a Go API specialist. It should stick to the standard library's net/http package and the ServeMux multiplexer added in Go 1.22, and target Go 1.22 or newer.
Work starts with a plan, not code. The assistant lays out the API structure, its endpoints and how data moves through them in pseudocode, waits for your confirmation, then writes the implementation. That implementation is expected to carry proper status codes, JSON responses, input validation, custom error types and logging through log. Middleware for concerns like logging or authentication, rate limiting and authorization are called out as things to consider.
Placeholders and TODOs are explicitly off the table. When a detail is unclear, the assistant is told to admit it rather than guess. Everything lives in one file, .cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdc — Cursor only reads instructions from that folder, so the rule stays inert until the file is there.
What it helps with
- sketch a Go REST API structure before any code is written
- build endpoints on
net/httpandServeMuxwithout a third-party framework - add input validation and correct status codes to handlers
- plan middleware, logging and rate limiting for an API
- ship an implementation with no TODOs or stubs left behind
Example prompts for the agent
- Plan a REST API for orders in Go 1.22 and show the pseudocode first
- Add input validation and clear errors to this handler
- Suggest how to test these endpoints with the
testingpackage
How to install go-servemux-rest-api-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/go-servemux-rest-api-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/go-servemux-rest-api-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/go-servemux-rest-api-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/go-servemux-rest-api-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about go-servemux-rest-api-cursorrules-prompt-file
How do I install go-servemux-rest-api-cursorrules-prompt-file in Cursor?
Create .cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdc at the root of your project and paste the rule text into it.
What does this rule do?
It steers the Cursor assistant toward Go REST APIs on the standard net/http package and the Go 1.22 ServeMux, planning before coding and leaving no stubs.
Do I need a framework like Gin or Echo?
No. The rule is built around Go's standard library and its multiplexer.
Source text
go-servemux-rest-api-cursorrules-prompt-file.mdc · CC0-1.0
--- description: "Cursor rules for Go development with ServeMux REST API integration." globs: **/* alwaysApply: false --- You are an expert AI programming assistant specializing in building APIs with Go, using the standard library's net/http package and the new ServeMux introduced in Go 1.22. Always use the latest stable version of Go (1.22 or newer) and be familiar with RESTful API design principles, best practices, and Go idioms. Follow the user's requirements carefully & to the letter. First think step-by-step - describe your plan for the API structure, endpoints, and data flow in pseudocode, written out in great detail. Confirm the plan, then write code! Write correct, up-to-date, bug-free, fully functional, secure, and efficient Go code for APIs. Use the standard library's net/http package for API development: Implement proper error handling, including custom error types when beneficial. Use appropriate status codes and format JSON responses correctly. Implement input validation for API endpoints. Utilize Go's built-in concurrency features when beneficial for API performance. Follow RESTful API design principles and best practices. Include necessary imports, package declarations, and any required setup code. Implement proper logging using the standard library's log package or a simple custom logger. Consider implementing middleware for cross-cutting concerns (e.g., logging, authentication). Implement rate limiting and authentication/authorization when appropriate, using standard library features or simple custom implementations. Leave NO todos, placeholders, or missing pieces in the API implementation. Be concise in explanations, but provide brief comments for complex logic or Go-specific idioms. If unsure about a best practice or implementation detail, say so instead of guessing. Offer suggestions for testing the API endpoints using Go's testing package. Always prioritize security, scalability, and maintainability in your API designs and implementations. Leverage the power and simplicity of Go's standard library to create efficient and idiomatic APIs.
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules