šŸ“š goscaf - Awesome Go Library for Command Line

Go Gopher mascot for goscaf

goscaf generates opinionated, production-quality Go project boilerplate via an interactive CLI. Stop copy-pasting skeleton code between projects

šŸ·ļø Command Line
šŸ“‚ Advanced Console UIs
⭐ 0 stars
View on GitHub šŸ”—

Detailed Description of goscaf

šŸš€ goscaf

Enterprise-grade Go project scaffolder

Go Version License: MIT CI Go Report Card GoDoc Visitors

Think create-react-app, but for Go services.


What is goscaf?

goscaf generates opinionated, production-quality Go project boilerplate via an interactive CLI. Stop copy-pasting skeleton code between projects. Start with:

  • Graceful shutdown with OS signal handling
  • Structured JSON logging (slog, zerolog, or zap)
  • Your choice of HTTP framework (gin, fiber, chi, echo, gorilla/mux)
  • Your choice of Database driver (postgres, mysql, sqlite, mongo, gorm)
  • Viper-powered config with .env support
  • Optional infra clients: Redis, Kafka, NATS
  • Multi-stage distroless Dockerfile + docker-compose
  • Makefile, GitHub Actions CI, golangci-lint - ready to go on day one

Install

Go install

go install github.com/iyashjayesh/goscaf@latest

Homebrew (coming soon)

brew install goscaf-dev/tap/goscaf

From source

git clone https://github.com/iyashjayesh/goscaf.git
cd goscaf
make install

Usage

Interactive mode

goscaf init my-api

Sample prompt flow:

? Module name: (github.com/your-org/my-api)
? Go version: (1.25.0)
? HTTP framework: gin
? Structured logger: slog (stdlib)
? Add Viper for config & env management? (Y/n)
? Add Redis client (go-redis)? (y/N)
? Add Kafka client (franz-go)? (y/N)
? Add NATS client? (y/N)
? Database driver: (none)
? Add Dockerfile + docker-compose? (Y/n)
? Add Makefile? (Y/n)
? Add GitHub Actions CI? (Y/n)
? Add golangci-lint config? (Y/n)
? Add Swagger/OpenAPI scaffold? (y/N)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Scaffolding project: my-api
  Module:    github.com/your-org/my-api
  Go:        1.25.0
  Framework: gin
  Logger:    slog
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  āœ“ cmd/main.go
  āœ“ go.mod
  āœ“ .gitignore
  āœ“ .env.example
  āœ“ internal/config/config.go
  āœ“ internal/handler/handler.go
  āœ“ internal/server/server.go
  āœ“ Dockerfile
  āœ“ docker-compose.yml
  āœ“ Makefile
  āœ“ .github/workflows/ci.yml
  āœ“ .golangci.yml
  → Running go mod tidy...
  āœ“ go mod tidy

  āœ” Project created successfully!

  Next steps:
    cd my-api
    cp .env.example .env
    make docker-up
    make run

Non-interactive / CI mode

goscaf init my-api --defaults
goscaf init my-api --framework fiber --logger zap --redis --kafka --docker

Flags

FlagDefaultDescription
--module""Go module path
--go-version1.25.0Go version (1.23, 1.24, 1.25)
--frameworkginHTTP framework (gin|fiber|chi|echo|gorilla|none)
--loggerslogStructured logger (slog|zerolog|zap)
--vipertrueAdd Viper for config & env management
--redisfalseAdd Redis client (go-redis/v9)
--kafkafalseAdd Kafka client (franz-go)
--natsfalseAdd NATS client
--dbnoneDatabase driver (postgres|mysql|sqlite|mongo|gorm|none)
--dockertrueAdd Dockerfile + docker-compose
--makefiletrueAdd Makefile
--githubtrueAdd GitHub Actions CI
--linttrueAdd golangci-lint config
--swaggerfalseAdd Swagger/OpenAPI scaffold
--defaultsfalseSkip all prompts, use recommended defaults
--output.Output directory

Generated Project Structure

my-api/
ā”œā”€ā”€ cmd/
│   └── main.go                  # Entrypoint with graceful shutdown
ā”œā”€ā”€ internal/
│   ā”œā”€ā”€ config/
│   │   └── config.go            # Viper (or stdlib) config loader
│   ā”œā”€ā”€ server/
│   │   └── server.go            # HTTP server for chosen framework
│   └── handler/
│       └── handler.go           # HTTP handlers
ā”œā”€ā”€ pkg/
│   ā”œā”€ā”€ db/db.go                 # (if selected) Database connection wrapper
│   ā”œā”€ā”€ redis/redis.go           # (if selected) go-redis wrapper
│   ā”œā”€ā”€ kafka/kafka.go           # (if selected) franz-go producer+consumer
│   └── nats/nats.go             # (if selected) NATS client wrapper
ā”œā”€ā”€ .github/
│   └── workflows/ci.yml
ā”œā”€ā”€ .env.example
ā”œā”€ā”€ .gitignore
ā”œā”€ā”€ .golangci.yml
ā”œā”€ā”€ Dockerfile
ā”œā”€ā”€ docker-compose.yml
ā”œā”€ā”€ go.mod
└── Makefile

Generated Makefile Targets

TargetDescription
make rungo run ./cmd/main.go
make buildBuild binary to bin/<name>
make testgo test -race -cover ./...
make test-coverageGenerate coverage.html report
make lintgolangci-lint run ./...
make fmtgofmt -s -w . && goimports -w .
make tidygo mod tidy
make docker-updocker compose up -d
make docker-downdocker compose down
make docker-logsdocker compose logs -f app
make cleanRemove bin/, coverage.*
make install-toolsInstall golangci-lint + goimports

Supported Frameworks

Flag valueImport path
gingithub.com/gin-gonic/gin
fibergithub.com/gofiber/fiber/v2
chigithub.com/go-chi/chi/v5
echogithub.com/labstack/echo/v4
gorillagithub.com/gorilla/mux
nonestdlib net/http

Supported Databases

Flag valueDriver / Library
postgresgithub.com/jackc/pgx/v5
mysqlgithub.com/go-sql-driver/mysql
sqlitemodernc.org/sqlite
mongogo.mongodb.org/mongo-driver
gormgorm.io/gorm (with Postgres driver)
noneNo database scaffolded

Contributing

# Clone and build
git clone https://github.com/iyashjayesh/goscaf.git
cd goscaf
make build

# Run the smoke test
make smoke-test

PRs welcome! Please open an issue first for major changes.