A template for building a CLI application build with Go and Urfave CLI.
- Go 54.3%
- Just 45.7%
|
|
||
|---|---|---|
| cmd/__ProjectName__ | ||
| internal/example | ||
| .gitignore | ||
| .gohatch.toml | ||
| .golangci.yml | ||
| .goreleaser.yaml | ||
| .pre-commit-config.yaml | ||
| go.mod | ||
| go.sum | ||
| justfile | ||
| LICENSE | ||
| README.md | ||
Go CLI Template
A ready-to-use template for Go CLI applications.
Stack
- Go 1.24+
- urfave/cli v3 for argument parsing and subcommands
- just task runner
- golangci-lint for code quality
- goreleaser for releases
Quick Start
# Create new project from template
gohatch codeberg.org/oliverandrich/go-cli-template codeberg.org/you/your-app
# Build and run
cd your-app
just build
./build/your-app
Requirements
- Go 1.24+
- gohatch
- just (command runner)
- golangci-lint (linting)
- tparse (test output formatting)
Template Variables
The template uses placeholders that gohatch replaces automatically:
| Placeholder | Replaced with |
|---|---|
__ProjectName__ |
Binary name (last path segment) |
__ProjectDescription__ |
Project description (from -d flag) |
Development
just setup # Setup project (download deps, install pre-commit hooks)
just build # Build binary to build/<name>
just test # Run tests
just cover # Run tests with coverage
just cover-report # Open coverage report in browser
just fmt # Format code
just lint # Run linter
just check # Run fmt, lint, and test
just clean # Remove build artifacts
just install # Install to $GOPATH/bin
just release # Create release with goreleaser
Project Structure
├── cmd/
│ └── __ProjectName__/ # CLI entry point
│ └── main.go
├── internal/ # Internal packages
│ └── example/ # Example package
├── go.mod
├── justfile # Task runner
├── .golangci.yml # Linter config
└── .goreleaser.yml # Release config
License
EUPL-1.2 - see LICENSE