Go CLI Application
Scaffolds a Go CLI application using Cobra for command structure, Viper for configuration management, and log/slog for structured logging. Produces a buildable binary with a root command, version subcommand, config file support, and a Makefile. Optionally includes GoReleaser configuration and a GitHub Actions release workflow.
| Name | go-cli |
| Version | 0.1.0 |
| Category | applications |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | go, cli, cobra, viper, slog |
| Source | templates/go-cli |
Render it
Three front doors, one catalog. Pick whichever suits the caller.
# CLI
npx @nanohype/sdk render go-cli --out ./my-app
# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "go-cli", variables);
# MCP — from an agent
get_template({ name: "go-cli" })Prerequisites
| Tool | Version | Why |
|---|---|---|
go | >=1.24 | Go compilation and module management |
goreleaser (optional) | >=2.0 | Automated release builds (only needed if release config is included) |
Variables
Required
ProjectNamestring- Kebab-case project name, used as binary name and directory Must be lowercase kebab-case starting with a letter.
Orgstring- GitHub organization or username Must be a valid GitHub org or username.
GoModulestring- Full Go module path Must be a valid Go module path.
Optional
Descriptionstring — defaults toA CLI application- Short project description for help text and README
IncludeReleasebool — defaults totrue- Include GoReleaser configuration and GitHub Actions release workflow
LogFormatenum — defaults tojson- Default structured log output format One of:
jsontextpretty.
What it produces
16 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.
.env.example
.github/workflows/ci.yml
.github/workflows/release.yml
.gitignore
.golangci.yml
.goreleaser.yaml
cmd/root_test.go
cmd/root.go
cmd/version.go
go.mod
go.sum
internal/config/config_test.go
internal/config/config.go
main.go
Makefile
README.mdComposes with
- Pairs with
eval-harness - Nests inside
monorepo
Composites that use it
- Internal Tool — CLI tool or browser extension backed by MCP servers for internal team use..