Forge production-ready Go applications with security, observability, and best practices built-in.
go install github.com/viveksharma/goforge@latestDownload pre-built binaries from the Releases page.
git clone https://github.com/viveksharma/goforge.git
cd goforge
make installThis installs the latest development version to $GOPATH/bin (usually ~/go/bin).
git clone https://github.com/viveksharma/goforge.git
cd goforge
go build -o goforge ./cmd/goforge
sudo mv goforge /usr/local/bin/Create a new project in seconds:
# Create with Fiber (high performance)
goforge create my-api -s fiber
# Create with Gin (feature-rich)
goforge create my-api -s ginBy default, your Go module will be named after your project (e.g., module my-api).
If you want a custom module path for GitHub/GitLab or organization projects:
# With custom module path
goforge create my-api -s fiber --module github.com/yourusername/my-api
# Short form
goforge create my-api -s fiber -m github.com/viveksharma/my-apicd my-api
make upYour API is now running at http://localhost:8080 π
Quick health check:
curl http://localhost:8080/health/readyEvery generated project includes:
- Fiber: Blazing-fast, Express-inspired framework with zero memory allocation router
- Gin: Feature-rich framework with excellent middleware ecosystem and proven track record
- Same Quality: Both options include identical security, observability, and production-ready features
- Security Headers: HSTS, CSP, X-Frame-Options, X-Content-Type-Options
- Input Validation: Path traversal protection, request validation
- No Sensitive Logging: Credentials never appear in logs
- Panic Recovery: Graceful error handling
- Rate Limiting Ready: Redis-backed rate limiting structure
- Secure Defaults: Non-root Docker user, read-only filesystem
- Timeouts: Request/connection timeouts prevent DoS
- Structured Logging: JSON logs with correlation IDs (zap)
- Health Checks: Kubernetes-ready
/health/liveand/health/ready - Prometheus Metrics: Built-in
/metricsendpoint with request counters, duration histograms, and in-flight gauges - Request Tracing: Unique request IDs for log correlation
- Error Tracking: Contextual error logging with stack traces
- Choice of Framework: Fiber (high-performance) or Gin (feature-rich)
- PostgreSQL: Production-grade database with connection pooling
- Redis: Caching layer with connection management
- Database Migrations: Built-in golang-migrate support with up/down/version/force commands
- Swagger/OpenAPI: Auto-generated API documentation at
/swagger/index.html - Docker Compose: Zero-config local development
- Graceful Shutdown: Connection draining on SIGTERM/SIGINT
- Environment Management: Type-safe
.envconfiguration
- Make Commands: Common tasks via Makefile
- Hot Reload Ready: Easy integration with Air or CompileDaemon
- Clean Architecture: Separation of concerns (handler/service/repository pattern ready)
- Dockerfile Included: Multi-stage build with security best practices
- Comprehensive README: Documentation generated with every project
your-project/
βββ cmd/api/ # Application entry point
βββ internal/
β βββ config/ # Environment configuration
β βββ handler/ # HTTP request handlers
β βββ middleware/ # HTTP middleware (security, logging, recovery, metrics)
β βββ server/ # Server setup and routing
βββ pkg/
β βββ logger/ # Structured logging
β βββ database/ # PostgreSQL client
β βββ cache/ # Redis client
β βββ migration/ # Database migration runner
βββ migrations/ # SQL migration files (up/down)
βββ docs/ # Swagger/OpenAPI documentation
βββ deployments/
β βββ Dockerfile # Multi-stage production build
βββ docker-compose.yml # Local development stack
βββ Makefile # Common commands
βββ .env.example # Environment variables template
- Path Traversal Prevention: Project name validation prevents
../attacks - SQL Injection Protection: Parameterized queries enforced
- XSS Protection: Security headers set by default
- Clickjacking Protection: X-Frame-Options: DENY
- MIME Sniffing Protection: X-Content-Type-Options: nosniff
- Request Timeout Protection: Read/write timeouts configured
- Body Size Limits: 4MB default limit
- Non-Root Docker User: Containers run as user 1000
- Read-Only Filesystem: Docker containers use read-only root
- Secrets Management:
.envfiles never committed
All generated code follows:
- OWASP Top 10 protection
- Principle of least privilege
- Defense in depth
- Secure defaults
- Input validation
- Output encoding (where applicable)
make up # Start all services (API, PostgreSQL, Redis)
make down # Stop all services
make logs # View logs
make build # Build the Go binary
make run # Run without Docker
make test # Run tests
make fmt # Format code
make lint # Run linter
make clean # Clean up
make swagger # Generate Swagger docs
make migrate-up # Run all pending migrations
make migrate-down # Revert last migration
make migrate-create # Create migration (NAME=migration_name)
make migrate-version # Show current migration version
make migrate-force # Force migration version (VERSION=1)Generated projects are fully customizable:
- Add your business logic in
internal/handler/ - Create services in
internal/service/ - Add repositories in
internal/repository/ - Update routes in
internal/server/server.go - Modify environment variables in
.env
Every project includes these environment variables:
| Variable | Description | Default |
|---|---|---|
APP_ENV |
Environment (development/production) | development |
APP_PORT |
HTTP server port | 8080 |
DATABASE_URL |
PostgreSQL connection string | Required |
REDIS_URL |
Redis connection string | Required |
LOG_LEVEL |
Logging level (debug/info/warn/error) | info |
Generated projects are deployment-ready for:
- Kubernetes: Health check endpoints configured
- Docker: Multi-stage Dockerfile included
- Cloud Run: Listens on PORT environment variable
- AWS ECS/Fargate: 12-factor app compliant
- Any platform: Standard REST API
Every generated project is test-ready:
cd my-project
make testAdd your tests in:
internal/handler/*_test.gointernal/service/*_test.gopkg/*_test.go
For quick prototyping or local projects, use the simple syntax:
goforge create my-api -s fiber
# Result: go.mod β module my-apiFor projects you'll push to GitHub or GitLab, specify the full module path:
goforge create my-api -s fiber -m github.com/yourusername/my-api
# Result: go.mod β module github.com/yourusername/my-apiFor company or organization projects:
goforge create payment-service -s gin -m gitlab.company.com/backend/payment-service
# Result: go.mod β module gitlab.company.com/backend/payment-service- β Creates project directory
- β Generates all project files with your chosen framework
- β Sets up PostgreSQL database with connection pooling
- β Configures Redis for caching
- β
Adds health check endpoints (
/health/live,/health/ready) - β Sets up database migrations system
- β
Generates Swagger/OpenAPI docs at
/swagger/index.html - β
Adds Prometheus metrics at
/metrics - β Includes Docker Compose for one-command startup
- β Creates comprehensive README with all commands
- β Downloads dependencies automatically
cd my-api
make up # Starts PostgreSQL, Redis, and your API
make logs # Watch the logs
# Test your API
curl http://localhost:8080/health/ready
curl http://localhost:8080/metrics
# View API docs
open http://localhost:8080/swagger/index.html- π You need maximum performance and minimal memory footprint
- π You prefer Express.js-like syntax and patterns
- β‘ Your application handles high concurrent loads
- ποΈ You want the fastest request/response times
- π‘οΈ You prefer a mature, battle-tested framework
- π§ You need extensive middleware ecosystem
- β You want built-in validation and binding
- π₯ Your team is already familiar with Gin
Both frameworks generate identical project structure and features - the only difference is the web framework implementation.
goforge create my-project -s fiberβ Perfect for:
- Quick prototypes and experiments
- Learning projects
- Local-only development
- Tools and scripts that won't be shared
Result: module my-project (simple and clean)
goforge create my-project -s fiber -m github.com/username/my-projectβ Perfect for:
- Projects you'll push to GitHub/GitLab
- Open source projects
- Company/organization codebases
- Projects with internal imports
Result: module github.com/username/my-project
# GitHub
goforge create api -s fiber -m github.com/viveksharma/api
# GitLab
goforge create service -s gin -m gitlab.com/myorg/service
# Self-hosted GitLab
goforge create payment -s fiber -m git.company.com/backend/payment
# Bitbucket
goforge create auth -s gin -m bitbucket.org/team/auth
# Company domain
goforge create users -s fiber -m go.company.com/services/usersContributions welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure all tests pass
- Submit a pull request
MIT License - feel free to use this for any project.
Found a bug or have a feature request? Open an issue on GitHub.
If this tool helped you, give it a star on GitHub!
Made with β€οΈ for the Go community