dev-resources.site
for different kinds of informations.
The GoTTH Stack
Published at
9/28/2024
Categories
go
tailwindcss
turso
htmx
Author
Amit Suthar
Main Article
GoTTH is designed to quickly spin up a Full-Stack Golang Web Application with HTMX, Tailwindcss and Turso SQLite database support.
About the Stack
Includes following Languages and Technologies:
- Golang with ServeMux.
- TailwindCSS Standalone Executable.
- Turso LibSQL (SQLite for Production).
- HTMX with Templ as Templating Engine.
Basic Project Guide
GOTTH
ā
āāā /internal/ # Private application and business logic
ā āāā /server/ # Server-specific logic
ā ā āāā server.go # Core server logic
ā ā āāā routes.go # Route definitions
ā āāā /database/ # Database-related logic
ā | āāā database.go # Database connection and queries
ā āāā /middleware/ # Middlewares
ā āāā logger.go # Logger middleware
ā
āāā /static/ # Static assets (CSS, JS, images, etc.)
ā āāā /css/ # CSS files
ā ā āāā input.css # Tailwind input file
ā ā āāā style.css # Generated CSS file
ā āāā /scripts/ # JavaScript files
ā āāā htmx.min.js # HTMX JavaScript library
ā
āāā /web/ # Web UI-related handlers
ā āāā hello.templ # Templating file for the hello page
ā āāā hello.go # Hello handler logic
ā
āāā main.go # Application entry point
āāā Makefile # Build automation scripts
āāā .air.toml # Air live reloading config file
āāā tailwind.config.js # Tailwind CSS configuration
āāā tailwindcss # Tailwind CSS binary
Run the project
air
Installation Guide
Air for Live Reload
go install github.com/cosmtrek/air@latest
Templ
go install github.com/a-h/templ/cmd/templ@latest
You can add templ
to your local bashrc or zshrc profile config to avoid absolute path while using templ
command.
TailwindCSS
Install the executable binary for your platform from the latest release from GitHub in the root of project.
Make sure to give it executable permissions:
chmod +x ./tailwindcss
Turso
go get github.com/tursodatabase/libsql-client-go/libsql
- Then Install the Turso CLI, create your database, generate the AuthToken & DB_URL and add them in the
.env
file. - You can refer this awesome Turso Quickstart Go Docs if you get stuck anywhere.
.env
PORT=8080
DB_URL=libsql://yourDBName-tursoUserName.turso.io?authToken=yourAuthToken
Featured ones: