A lightweight CLI tool for scaffolding and managing Go projects. Garnet helps you quickly spin up new services from templates and provides convenient commands for running, building, and developing your Go applications.
go install github.com/datcchaa/garnet@latestMake sure your $GOPATH/bin is in your $PATH to run the garnet command globally.
Create a new project:
garnet generate my-service
cd my-service
go mod tidy
make run-apiThat's it. You now have a working Go service running locally.
Scaffolds a new project from the garnet-scaff template.
garnet generate payment-serviceThis will:
- Clone the template repository
- Replace module names with your project name
- Initialize a fresh git repository
- Set up the basic project structure
After generation, follow the printed instructions to get started.
Runs your Go project. If a Makefile exists with a run-api target, it uses that. Otherwise, it falls back to go run main.go serve-http.
# Run the current directory
garnet run
# Run a specific project
garnet run ./payment-serviceDependencies are automatically tidied before running.
Starts your project with hot reload using Air. If Air isn't installed, Garnet will install it for you. If no .air.toml config exists, one will be generated.
garnet devNow you can edit your code and see changes reflected immediately without manually restarting the server.
Compiles your project into an executable binary. The output is placed in the bin/ directory.
garnet buildThe binary is built from cmd/api/main.go and named after your project.
Generated projects follow this structure:
my-service/
├── cmd/
│ └── api/
│ └── main.go
├── go.mod
├── Makefile
└── ... (additional template files)
The template is opinionated but flexible enough to adapt to your needs.
- Go 1.25.3 or later
- Git (for cloning templates)
- Make (optional, but recommended)
I built this because I was tired of manually setting up the same project structure every time I started a new service. Copy-pasting from old projects works, but it's messy and you end up with outdated dependencies or leftover code.
Garnet keeps things simple. It's not trying to be a framework or enforce a specific architecture. It just handles the boring parts so you can get to writing actual code faster.
Found a bug or have a feature idea? Open an issue or submit a PR. Contributions are welcome.
MIT