Logo

dev-resources.site

for different kinds of informations.

The GoTTH Stack

Published at
9/28/2024
Categories
go
tailwindcss
turso
htmx
Author
Amit Suthar
Categories
4 categories in total
go
open
tailwindcss
open
turso
open
htmx
open
The GoTTH Stack

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:

  1. Golang with ServeMux.
  2. TailwindCSS Standalone Executable.
  3. Turso LibSQL (SQLite for Production).
  4. 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

  1. Install the executable binary for your platform from the latest release from GitHub in the root of project.

  2. Make sure to give it executable permissions:

chmod +x ./tailwindcss

Turso

go get github.com/tursodatabase/libsql-client-go/libsql
  1. Then Install the Turso CLI, create your database, generate the AuthToken & DB_URL and add them in the .env file.
  2. 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

GoTTH

Featured ones: