Personal blog rewritten from Laravel to Go using Textwire templating. Learning project exploring Go with a real-world application using Textwire (custom templating language by the same author).
Build a project for development using Dockerfile.dev file:
make buildStart a development server with autorefresh:
make upCreates a vendor directory in your root project. Good for LSP:
make vendorEnter a development container:
make shellBuild image for production using Dockerfile.prod file:
make buildprodStart a production server on port 80:
make upprodEnter a production container:
make shellprod- Go 1.26 with standard library http
- Textwire v3 for templating (github.com/textwire/textwire/v3)
- MySQL 8.0 with go-sql-driver/mysql
- Vue 3 + TypeScript + Tailwind CSS v4
- Vite build tool
- Podman for containers
make up # Start containers and enter shell (default)
make shell # Enter running app container
make down # Stop containers
make build # Build containers
make restart # Restart with dev mode
make dev # Run Vite dev server (inside container)
make run # Run Go app locally (run when you are inside of a container)
make db # Enter MySQL shell
make backup # Restore from backup.sqlgo test ./... # Run all tests
go test -run TestName ./path # Run specific test
go fmt ./... # Format code
go vet ./... # Static analysisnpm run dev # Vite dev server (port 5173)
npm run build # Production buildKey Directives:
@use("~main")- extend layout (~ = templates root)@insert("title", "content")- define section content@component("~path/component", { props })@end- render component@passand@passif- component content block@slotfor placeholders in component files{{ variable }}- output (auto-escaped){{ defined(var) ? var : 'default' }}- conditional with default
Naming Conventions:
- Layouts:
~main,~admin - Components:
~home/section,~icons/arrow-right - Partials:
~partials/head,~partials/navbar - Views: no prefix (resolved relative to templates/)
Global Data (available in all templates):
Access via global. prefix:
global.env- APP_ENV valueglobal.appName- APP_NAME valueglobal.darkThemeCookie- theme preferenceglobal.manifest.js/css- Vite manifest entries
Entry Points:
- Main:
web/ts/main/app.ts+web/css/main/app.css - Admin:
web/ts/admin/app.ts+web/css/admin/app.css
Aliases (Vite):
@/→web/ts/main/@admin/→web/ts/admin/@user/→web/ts/user/@shared/→web/ts/shared/
Conventions:
- Vue 3 Composition API with
<script setup> - Tailwind v4: use
@import "tailwindcss"in CSS - TypeScript strict mode
Required variables (see .env.example):
APP_NAME,APP_ENV,APP_PORTDB_HOST,DB_PORT,DB_DATABASE,DB_USERNAME,DB_PASSWORD
- Textwire auto-reloads templates in development (
FileWatcher: true) - MySQL connection pooling configured (max 20 connections)
- Vite HMR on port 5173, app on port 8080
- Public files served from
./publicdirectory - Template components receive props as object parameter
No tests exist yet. Use standard Go testing:
- Test files:
*_test.goalongside source files - Run:
go test ./... - Single test:
go test -run TestName ./package
- Create handler in
internal/http/handlers.go - Register route in
internal/http/server.go - Create template in
templates/views/ - Use
@use('~main')to extendlayouts/main.tw(~an alias forlayouts/) - Use
@insert('title', 'Some title')adn@insert('content')@endto insert things into a layout file
- Add interface method to
internal/database/database.go - Implement in
internal/database/mysql/{entity}.go - Return
([]*model.Entity, error)or(*model.Entity, error)
- Create
.twfile intemplates/components/{category}/ - Use
@passfor content injection - Access props with
{{ defined(propName) ? propName : 'default' }} - Reference with
~prefix:@component("~category/name", { prop: value })@end(~an alias forcomponents/)
- All Textwire files end with
.twfile extension - Templates live in
./templates/ - Components live in
./templates/components/ - Layouts live in
./templates/layouts/ - Views live in
./templates/views/