go-servemux-rest-api-cursorrules-prompt-file — правило для Cursor
Правило для Cursor, которое настраивает ассистента писать REST API на Go через net/http и новый ServeMux из Go 1.22.
.cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdcЧто делает go-servemux-rest-api-cursorrules-prompt-file
Правило задаёт ассистенту роль специалиста по API на Go. Он должен работать со стандартной библиотекой net/http и мультиплексором ServeMux, появившимся в Go 1.22, а версию языка брать не ниже 1.22.
Перед кодом ассистент расписывает план: структуру API, эндпоинты и поток данных в псевдокоде. Дальше вы подтверждаете план, и только после этого он пишет код. В самом коде ожидаются корректные статус-коды, JSON-ответы, валидация входных данных, обработка ошибок с собственными типами и логирование через log. Отдельно правило просит подумать о middleware для сквозных задач, ограничении частоты запросов и авторизации, если это уместно.
Готовых заглушек и TODO в реализации быть не должно — это прямо прописано. Если ассистент не уверен в детали, он должен сказать об этом, а не догадываться. Установка сводится к одному файлу .cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdc, и без него правило не подхватится: Cursor читает инструкции только из этой папки.
Какие задачи решает
- спроектировать структуру REST API на Go до написания кода
- получить эндпоинты на
net/httpиServeMuxбез сторонних фреймворков - добавить валидацию входных данных и корректные статус-коды
- заложить middleware, логирование и ограничение частоты запросов
- избежать заглушек и незакрытых TODO в готовом коде
Примеры запросов агенту
- Спланируй REST API для заказов на Go 1.22 и покажи псевдокод перед кодом
- Добавь в этот обработчик валидацию входных данных и понятные ошибки
- Предложи, как протестировать эти эндпоинты через пакет
testing
Как установить go-servemux-rest-api-cursorrules-prompt-file
Вручную: положить файлы
.cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/go-servemux-rest-api-cursorrules-prompt-file.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/go-servemux-rest-api-cursorrules-prompt-file.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/go-servemux-rest-api-cursorrules-prompt-file.mdВручную: положить файлы
.clinerules/go-servemux-rest-api-cursorrules-prompt-file.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Вопросы о go-servemux-rest-api-cursorrules-prompt-file
Как установить go-servemux-rest-api-cursorrules-prompt-file в Cursor?
Создайте файл .cursor/rules/go-servemux-rest-api-cursorrules-prompt-file.mdc в корне проекта и вставьте в него текст правила.
Что делает это правило?
Оно настраивает ассистента Cursor на разработку REST API на Go через стандартный net/http и ServeMux из Go 1.22, с планом до кода и без заглушек.
Нужен ли фреймворк вроде Gin или Echo?
Нет, правило ориентировано на стандартную библиотеку Go и её мультиплексор.
Исходный текст
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