CRUD application built with Go and HTMX for managing a collection of dogs. Use server-side rendering and HTMX for real-time updates without JavaScript.
- Create, read, update, delete dogs
- Real-time UI updates via HTMX
- Server-side rendering with Go templates
- Thread-safe operations with atomic integers
- Tailwind CSS styling
- Go 1.23.4+
- air (live reload)
- Tailwind CSS CLI
-
Install required tools:
# Install air for live reload go install github.com/air-verse/air@latest # Install Tailwind CSS CLI # macOS brew install tailwindcss # Windows (scoop) scoop install tailwindcss # Linux curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 chmod +x tailwindcss-linux-x64 sudo mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss
-
Get the code and dependencies:
git clone https://github.com/username/go-htmx-demo.git cd go-htmx-demo just update # Updates Go dependencies
# Update Go dependencies
just update
# Start development server with hot reload
just run
The just run
command:
- Start Go server at http://localhost:4000
- Watches for file changes and rebuilds
- Auto-recompiles Tailwind CSS
- Handles cleanup on exit
.
├── cmd/web/ # Main application code
│ ├── handlers.go # HTTP request handlers
│ ├── main.go # Application entry point
│ ├── models.go # Data structures and logic
│ └── routes.go # URL routing configuration
├── ui/ # Frontend assets
│ ├── assets/ # Source files
│ │ └── input.css # Source Tailwind CSS
│ ├── embed.go # Static file embedding
│ ├── html/ # Go templates
│ │ ├── base.tmpl # Base layout
│ │ ├── pages/ # Page templates
│ │ └── partials/ # Reusable components
│ └── static/ # Compiled assets
│ ├── css/ # Compiled CSS
│ └── js/ # JavaScript libraries
├── justfile # Development commands
└── tailwind.config.js # Tailwind CSS config
cmd/web/models.go
: Dog data structure and operationscmd/web/handlers.go
: HTTP handlers for CRUD operationscmd/web/routes.go
: URL routing setupui/html/pages/dogs.tmpl
: Main dogs page template with HTMX partialsjustfile
: Development automation commands
MIT License - See LICENSE file for details