machichdigital
RegelCursor RulesLizenz: CC0 1.0frei kopierbar

Htmx Go Basic

Cursor-Regel für HTMX mit Go-Standardbibliothek: schlanke Handler und html/template statt Framework.

⬇ Als Datei laden

× kopiert× heruntergeladenBewertung:

Cursor-Regel für HTMX mit Go-Standardbibliothek: schlanke Handler und html/template statt Framework.

Original-Beschreibung der Autoren: Cursor rules for Go development with basic setup.

Die Regel

---
description: "Cursor rules for Go development with basic setup."
globs: **/*
alwaysApply: false
---
// 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 = `
1. Use semantic HTML5 elements with HTMX attributes
2. Implement proper CSRF protection
3. Utilize HTMX extensions when needed
4. Use hx-boost for full page navigation
5. Follow Go's idiomatic error handling
6. Implement graceful shutdown for the server
7. Use Go modules for dependency management
`;

So nutzt du sie

Die Regel kopieren (Button oben) oder als Datei herunterladen und im Projekt unter .cursor/rules/ ablegen — Cursor lädt sie beim nächsten Start automatisch. Ältere Cursor-Versionen lesen alternativ eine einzelne .cursorrules-Datei im Projektstamm; dort einfach den Regel-Text ohne den Kopfblock zwischen den ----Zeilen einfügen.

Der Regel-Text ist englisch — Cursor versteht ihn unabhängig von der Sprache, in der Sie mit dem Editor chatten.

Im Detail

HTMX-Konventionen für Go-Backends ohne festgelegtes Web-Framework: Standardbibliothek net/http oder minimalistische Router, HTML-Templates via html/template, saubere Trennung von Partial- und Full-Page-Handlern. Richtet sich an Go-Entwickler, die bewusst schlank bleiben und weder ein schweres Framework noch ein JS-SPA wollen. Für Projekte mit Fiber als Router gibt es die spezifischere Fiber-Variante dieser Regel.

Praxis-Tipp

Aktivieren, wenn Go pur mit net/http eingesetzt wird, z. B. „Erstelle einen HTMX-Handler, der nur die Tabellenzeile neu rendert“ — Cursor bleibt dann bei html/template statt eine API-Schicht vorzuschlagen.

Lizenz & Quelle

Inhalt ansehen (htmx-go-basic.mdc)
Lade …

Erfahrungen & Kommentare.

Funktioniert der Regel bei Ihnen? Tipps, Stolperfallen, Varianten — teilen Sie es mit der Community.

Lade Kommentare …

Ihre IP-Adresse wird zum Schutz vor Missbrauch gespeichert und nach 14 Tagen automatisch entfernt (Datenschutz).

Passt dazu.