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.
css
dockerfile
go
golang
javascript
First Time Repository
MP Emailer is a web app that helps constituents easily contact their MPs through email campaigns on important issues.
Go
Languages:
CSS: 0.2KB
Dockerfile: 1.7KB
Go: 215.9KB
JavaScript: 3.0KB
Created: 9/6/2024
Updated: 11/23/2024
All Repositories (1)
MP Emailer is a web app that helps constituents easily contact their MPs through email campaigns on important issues.