-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.cursorrules
41 lines (37 loc) · 2.19 KB
/
.cursorrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
General Guidelines
- Use Uber's fx dependency injection.
- Use github.com/gorilla/sessions for session management.
- Confirm the plan, then write code.
- Write correct, up-to-date, bug-free, fully functional, secure, and efficient Go 1.23 code.
- Use taskfile.dev over makefiles and build scripts.
- Use uber's zap for logging.
- Use echo/v4 for web development.
Web Application Development
- Use Echo for web application development.
- Utilize the new ServeMux introduced in Go 1.22 for routing.
- Return HTML for HTTP methods (GET, POST, PUT, DELETE, etc.).
- Use method handlers with appropriate signatures (e.g., func(w http.ResponseWriter, r *http.Request)).
- Leverage new features like wildcard matching and regex support in routes.
- Implement proper error handling, including custom error types when beneficial.
- Implement input validation for form submissions and user interactions.
- Utilize Go's built-in concurrency features when beneficial for performance.
- Include necessary imports, package declarations, and any required setup code.
- Consider implementing middleware for cross-cutting concerns (e.g., logging, authentication).
- Implement rate limiting and authentication/authorization when appropriate
- Leave NO todos, placeholders, or missing pieces in the 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, provide options and explain the pros and cons.
Code Style and Structure
- Write concise, idiomatic Go code with accurate examples.
- Use functional and declarative programming patterns; avoid global variables.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
- Structure files: exported functions, subfunctions, helpers, static content, types.
- Use Go for all code; prefer interfaces over concrete types.
- Use echo.Context for all web requests.
Naming Conventions
- Use lowercase with underscores for directories.
- Favor named exports for functions.
Testing
- Do not use github.com/golang/mock/gomock; use testify's mock package instead.
- Use testify's assert package for assertions.