Getting Started

This guide takes you from zero to a deployed service in about ten minutes. You'll build a small JSON API, then a web app with a database, and finally a production binary.

You need: Go 1.26+, make, and Git. Docker is optional and only needed for container images.


1. Install the CLI

go install github.com/WhoseBiasDoYallSeek/fgoths-framework/cmd/fgoths@latest
fgoths version              # version: 1.4.1

This puts fgoths in $(go env GOPATH)/bin, so make sure that folder is on your PATH. Prefer building from source? See Install.


2. Your first API

fgoths init --name=orders --preset=api
cd orders
make dev

make dev starts the server on :8080 and restarts it every time you save a .go file. In another terminal:

curl localhost:8080/health          # {"status":"ok"}
curl localhost:8080/status          # {"service":"orders","status":"up"}

What was generated

orders/
├── main.go          ← routes live here
├── handlers/        ← your code goes here
├── pkg/runtime/     ← the embedded FGOTHS runtime (you rarely touch it)
├── cmd/dev/         ← the hot-reload watcher used by `make dev`
├── Makefile
└── Dockerfile

It is a plain Go module. There is no hidden framework import, and everything the service does is in this folder.

Add an endpoint

Create handlers/orders.go:

package handlers

import (
	"net/http"

	"orders/pkg/runtime"
)

func GetOrder(w http.ResponseWriter, r *http.Request) {
	id := runtime.PathValue(r, "id")
	writeJSON(w, http.StatusOK, map[string]any{"id": id, "status": "pending"})
}

Register it in main.go, next to the existing routes:

server.Get("/orders/{id}", handlers.GetOrder)

Save, and the server restarts on its own:

curl localhost:8080/orders/42       # {"id":"42","status":"pending"}

The server also has Post, Put, Patch, Delete, Any, and Use (for middleware). Use runtime.PathValue to read {params}.

Test it

make test                # go test ./...
go test -race ./...      # recommended before shipping

The generated handlers/handlers_test.go shows the pattern: an httptest.Recorder and a direct handler call, with no server to start.


3. A web app with a database

fgoths init --name=shop --preset=webapp
cd shop
make dev                            # → http://localhost:8080

The webapp preset adds:

  • views/: Templ components, compiled to Go, so templates are type-checked;
  • models/ and internal/database/: SQLite with embedded migrations;
  • static/: CSS and JS. In development, the browser reloads automatically when you save a view, a stylesheet, or a script.

Scaffold a resource

fgoths generate crud Product name:string price:float64 in_stock:bool

This creates the model, repository, handler, SQL migration, and tests, and registers the full resource for you: list, create, read, update, and delete.

curl -X POST localhost:8080/api/products \
  -d '{"name":"Coffee","price":12.5,"in_stock":true}'
curl localhost:8080/api/products
curl localhost:8080/api/products/1
curl -X PUT localhost:8080/api/products/1 \
  -d '{"name":"Espresso","price":9,"in_stock":true}'
curl -X DELETE localhost:8080/api/products/1

Field types: string, bool, int, int64, float64. Write entity names in PascalCase and field names in lower_snake.


4. Add features

Pick features when you create a project:

fgoths init --name=billing --preset=api --db=postgres --features=metrics,openapi,jwt-auth

Each feature adds code, and dependencies only when it truly needs them. Run fgoths presets or see the CLI reference for the full list.


5. Ship it

As a single binary

make build                          # → bin/app (static Linux binary, ~6 MB)
scp bin/app server:/opt/orders/
ssh server systemctl restart orders

The binary has no runtime dependencies: no Go, no libc, and no container engine on the server.

As a container

make docker-build                   # FROM scratch image, under 10 MB
make docker-run

With an SBOM

fgoths build --scratch --sbom       # binary + Dockerfile + software bill of materials

6. Keep it up to date

New FGOTHS releases never change your project on their own. When you want the latest runtime fixes, run:

fgoths upgrade --dir=.              # preview
fgoths upgrade --dir=. --apply      # apply

See Upgrading for the details.


Where next