Skip to content

datcchaa/garnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Garnet

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.

Installation

go install github.com/datcchaa/garnet@latest

Make sure your $GOPATH/bin is in your $PATH to run the garnet command globally.

Quick Start

Create a new project:

garnet generate my-service
cd my-service
go mod tidy
make run-api

That's it. You now have a working Go service running locally.

Commands

generate

Scaffolds a new project from the garnet-scaff template.

garnet generate payment-service

This 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.

run

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-service

Dependencies are automatically tidied before running.

dev

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 dev

Now you can edit your code and see changes reflected immediately without manually restarting the server.

build

Compiles your project into an executable binary. The output is placed in the bin/ directory.

garnet build

The binary is built from cmd/api/main.go and named after your project.

Project Structure

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.

Requirements

  • Go 1.25.3 or later
  • Git (for cloning templates)
  • Make (optional, but recommended)

Why Garnet?

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.

Contributing

Found a bug or have a feature idea? Open an issue or submit a PR. Contributions are welcome.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages