.cursorrules Htmx Go Basic

HTMX with Go Development Guidelines

A set of best practices and instructions for integrating HTMX with Go, focusing on efficient and secure development:

HTMX and Go Best Practices

  • Use Go’s html/template for server-side rendering and http.HandlerFunc for handling HTMX requests.
  • Utilize gorilla/mux for routing if needed and encoding/json for JSON responses.
  • Implement proper error handling and logging, and use context for request cancellation and timeouts.

Folder Structure

Organize code into a structured directory:

textcmd/
  main.go
internal/
  handlers/
  models/
  templates/
static/
  css/
  js/
go.mod
go.sum

Additional Instructions

  • Use semantic HTML5 elements with HTMX attributes.
  • Implement proper CSRF protection.
  • Utilize HTMX extensions when necessary and hx-boost for full page navigation.
  • Follow Go’s idiomatic error handling and implement graceful server shutdown.
  • Use Go modules for dependency management.

Overview of .cursorrules prompt

This prompt provides guidelines for integrating HTMX with Go, focusing on best practices for dynamic web development. It emphasizes using Go’s templating and routing capabilities alongside HTMX’s interactive features, while ensuring proper error handling, security, and dependency management. By following these guidelines, developers can build responsive web applications that leverage the strengths of both HTMX and Go, maintaining efficiency and security.

Updated: March 15, 2025
This prompt outlines integrating HTMX with Go for dynamic web development, emphasizing best practices for templating, routing, and security.
Usefull for: