htmx go basic
via PatrickJS/awesome-cursorrules
Go server-side rendering with HTMX for interactive web applications
What is htmx go basic?
Basic setup guide for building HTMX-powered web applications in Go using server-side rendering. Use this rule when starting a new Go + HTMX project to establish routing, templating, and request handling patterns.
- Use html/template for server-side rendering with HTMX attributes
- Handle HTMX requests with http.HandlerFunc and gorilla/mux routing
- Implement CSRF protection and HTMX extensions for enhanced interactivity
- Organize code with cmd/, internal/handlers, internal/models, and internal/templates directories
- Apply Go idiomatic error handling, context usage, and graceful server shutdown
- Use semantic HTML5 with hx-boost for full-page navigation and dynamic content updates
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
// HTMX with Go (Basic Setup) .cursorrules
// HTMX and Go best practices
const htmxGoBestPractices = [ "Use html/template for server-side rendering", "Implement http.HandlerFunc for handling HTMX requests", "Utilize gorilla/mux for routing if needed", "Use encoding/json for JSON responses", "Implement proper error handling and logging", "Utilize context for request cancellation and timeouts", ];
// Folder structure
const folderStructure = cmd/ main.go internal/ handlers/ models/ templates/ static/ css/ js/ go.mod go.sum;
// Additional instructions
const additionalInstructions = `
- Use semantic HTML5 elements with HTMX attributes
- Implement proper CSRF protection
- Utilize HTMX extensions when needed
- Use hx-boost for full page navigation
- Follow Go's idiomatic error handling
- Implement graceful shutdown for the server
- Use Go modules for dependency management `;
Related rules
Senior full-stack TypeScript, React, Node.js guidance with clean architecture, testing, and WHY-oriented reasoning.
Quantitative factor research skills for designing, evaluating, and mining alpha factors in equities markets.
Android development with Jetpack Compose, clean architecture, and Material Design 3.
Angular development with Novo Elements UI library using standalone components.
Expert Angular 18 + TypeScript development with Jest, emphasizing clean code and performance.
Manage Kubernetes clusters, add-ons, stacks, and credentials via the Ankra CLI platform.