The French Software Go webapp template
A modern Go web application template with server-side rendering, Google OAuth authentication, and type-safe HTML generation.
- Go 1.25 - Backend language
- libhtml - Type-safe HTML generation library
- Basecoat UI - Tailwind CSS component library
- TailwindCSS - Utility-first CSS framework
- SQLite - Embedded database (via modernc.org/sqlite)
- Google OAuth 2.0 - Authentication
- Air - Hot reload for development
- Go 1.25+ - Download
- Bun - Required for TailwindCSS bundling: Installation
- Clone the repository:
git clone <your-repo-url>
cd go-webapp-template- Install Go dependencies:
go mod download- Install Air for hot reload:
go install github.com/air-verse/air@latest- Set up environment variables:
cp .env.example .env
# Edit .env with your Google OAuth credentials- Get Google OAuth credentials:
- Visit Google Cloud Console
- Create OAuth 2.0 Client ID
- Add authorized redirect URI:
http://localhost:8080/auth/google/callback - Copy Client ID and Client Secret to
.env
Start the development server with hot reload:
make devThis will:
- Build and run the Go server
- Automatically rebuild CSS with TailwindCSS on file changes
- Hot reload the browser on Go/HTML/CSS changes
- Server runs at http://localhost:8080
Build CSS once:
make cssWatch CSS for changes (alternative to make dev):
make css-watchmake build # Build production binary to bin/server
make clean # Remove build artifacts (tmp/, bin/, public/styles.css)Pages are rendered server-side using Go with the libhtml library for type-safe HTML generation:
import "github.com/frenchsoftware/libhtml"
func MyPage(w http.ResponseWriter, r *http.Request) error {
page := html.Div(
attr.Class("container mx-auto"),
html.H1(html.Text("Hello World")),
)
return page.Render(w)
}The template includes Basecoat UI, a Tailwind CSS component library that works without React. Use pre-built component classes:
html.Button(
attr.Class("btn-primary"),
html.Text("Click Me")
)Available components: buttons, cards, forms, dialogs, badges, alerts, tables, tabs, and more. See views/basecoat.css or Basecoat UI documentation.
Environment variables (.env):
| Variable | Description | Default |
|---|---|---|
HTTP_ADDR |
Server address and port | :8080 |
DATABASE_URL |
SQLite database file path | file:app.db |
BASE_URL |
Application base URL (for OAuth) | http://localhost:8080 |
GOOGLE_CLIENT_ID |
Google OAuth Client ID | Required |
GOOGLE_CLIENT_SECRET |
Google OAuth Client Secret | Required |
- Build the binary:
make build-
Set production environment variables
-
Run the server:
./bin/serverThe SQLite database will be created automatically on first run.