Rename the module, CLI command name, and all references from keystone/basalt to draft, and fix the stale build/README content found along the way.
3.5 KiB
Draft
A powerful CLI tool for bootstrapping Go API projects with best practices built-in. Draft helps you quickly scaffold production-ready Go APIs with support for both HTTP (REST) and gRPC architectures.
Features
- 🚀 Quick Project Scaffolding - Generate complete API projects with a single command
- 🔄 Multiple API Types - Support for both HTTP (REST) and gRPC architectures
- 📦 Service Generation - Easily create new services with proper structure
- 🎯 Handler Generation - Generate HTTP or gRPC handlers on-demand
- 🔐 Cryptographic Key Generator - Built-in secure key generation
- 🛠️ Pre-configured Tooling - Automatic installation of essential Go tools
- 📝 Template-based - Consistent code generation using embedded templates
Installation
From Source
git clone [email protected]:FernandoJVideira/draft.git
cd draft
make build
Build for Different Platforms
# macOS (ARM64)
make mac
# Linux (AMD64)
make linux
# Windows (AMD64)
make windows
# Windows (ARM64)
make win-arm
The compiled binary will be named draft_<os>_<arch> (e.g. draft_darwin_arm64, or draft_windows_amd64.exe on Windows).
Usage
Create a New API Project
draft new api
This interactive command will:
- Prompt you for a project name (module name)
- Ask you to select an API type (HTTP REST or gRPC)
- Scaffold the complete project structure
- Install required development tools
- Run
go mod tidyto organize dependencies
Tools Automatically Installed:
air- Live reload for Go appsgolangci-lint- Go linters aggregatormockgen- Mock generation for testingsqlc- SQL compiler for type-safe database codemigrate- Database migration toolswag- Swagger documentation (HTTP only)protoc-gen-*- Protocol Buffer generators (gRPC only)
Generate a New Service
draft new service
Creates a new service file in internal/service/ with:
- Service interface definition
- Service struct implementation
- Compile-time interface checks
Generate a New Handler
draft new handler
Creates a new handler in the appropriate directory:
- HTTP handlers →
internal/handlers/http/ - gRPC handlers →
internal/handlers/grpc/
Generate a Cryptographic Key
draft new key
Generates a secure random key for use in your application (default: 32 characters).
Check Version
draft version
Project Structure
When you create a new project, Draft generates a structured Go API with:
your-project/
├── cmd/
│ └── api/
│ └── main.go
├── internal/
│ ├── handlers/
│ │ ├── http/ (if HTTP selected)
│ │ └── grpc/ (if gRPC selected)
│ └── service/
├── proto/ (if gRPC selected)
├── pb/ (if gRPC selected)
└── go.mod
Requirements
- Go 1.25.5 or higher
- Make (for building from source)
Dependencies
- Cobra - CLI framework
- promptui - Interactive prompts
- golang.org/x/text - Text processing utilities
Development
Build
make build
Run with Version Flag
make version
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Built by LKResuts for internal usage to bootstrap Go APIs.