Quick Start
Create your first GoFire API in 5 steps.
1. Create project
When to use which?
| Scenario | Command |
|---|---|
| Starting from scratch — no project yet | gofire new my-api |
Existing project — already have go.mod | gofire init |
Option A — From scratch (one command creates everything):
gofire new my-api
cd my-api
gofire new creates the directory, runs go mod init, adds goFire, generates api.yaml, handlers, server, and .gitignore. Ready to run immediately.
Option B — Existing Go project (manual setup):
mkdir my-api && cd my-api
go mod init my-api
go get github.com/messivite/goFire
gofire init
gofire init adds api.yaml and cmd/server/main.go to the current directory. Requires go.mod. Run gofire gen next to generate handlers and server.
Custom layout (pkg/server, pkg/handler)? Define paths once in .gofire.yaml or api.yaml output section. Then gofire gen uses them without flags. Resolution: CLI flag > .gofire.yaml > api.yaml output > default. See api.yaml output and Custom layouts.
Important: gofire gen requires go.mod. Do not skip these steps.
2. Configure
gofire setup
Configure port, Firebase credentials and Redis interactively. You can save values to .env.
3. Add endpoints
gofire add endpoint "GET /users"
gofire add endpoint "POST /users" --auth
gofire add endpoint "GET /users/:id" --auth
--auth protects the endpoint with Firebase Auth. Note: --auth must be outside the quotes.
4. Generate code
gofire gen
go mod tidy
Generates handler stubs, handlers/registry.go, and server routes. The server loads api.yaml at runtime, so when you add endpoints later with gofire add, running gofire gen again is enough — no server regenerate needed. Use gofire gen --handlers-only for custom server projects.
5. Run server
gofire init already created cmd/server/main.go. After gofire gen, run:
go run ./cmd/server
Server runs at http://localhost:8080 by default. Run go run ./cmd/server from the project root (inside my-api/).
missing go.sum / not a main package? Run go mod tidy. Use go run ./cmd/server instead of go run ..