From Zero to Go Hero: Pre-wired Template for Modern Libraries
| CI / CD | Quality & Security | Docs & Meta | Community | 
|---|---|---|---|
| 
        
           | 
      
        
           | 
      
        
           | 
      
        
           | 
    
- What's Inside
 - Installation
 - Documentation
 - Examples & Tests
 - Benchmarks
 - Code Standards
 - AI Compliance
 - Maintainers
 - Contributing
 - License
 
go-template is a plug-and-play scaffold that lets you skip the boilerplate and jump straight to building your Go library. Clone it, rename a few placeholders, and you instantly inherit a production-grade setup:
- 
📚 Go Best Practices & Examples Includes idiomatic Go patterns, table-driven tests, benchmarks, example functions, and fuzz tests—demonstrating how to write robust, maintainable, and production-grade Go code.
 - 
⚡ Zero-config CI/CD GitHub Actions run tests, upload coverage, and enforce linting on every push—so you never forget to run the checks.
 - 
🛠️ One-command via MAGE-X
magex test,magex lint,magex bench, and more—common tasks stay muscle-memory simple. - 
🚢 Automated Releases GoReleaser cuts signed, versioned artifacts the moment you push a tag—shipping new versions becomes a 10-second ritual.
 - 
🛡️ Security & Supply-chain Guardrails Dependabot, Nancy, govulncheck, CodeQL, OpenSSF Scorecard and gitleaks give early warnings before bad things reach production.
 - 
🎨 Style & Quality Enforcement golangci-lint with 50+ linters and gofumpt keeps the codebase clean and idiomatic - no bikeshedding required.
 - 
🤖 AI-Friendly Policies AGENTS.md, CLAUDE.md, cursorrules, and sweep.yaml ensure ChatGPT, Claude, Cursor & Sweep follow the same house rules.
 - 
🌍 Community-Ready Meta Issue/PR templates, CODEOWNERS, CITATION, label sync, and a welcome bot to show contributors exactly how to get involved.
 
- Clone → Tag → Release: Go from idea to a published version in under five minutes.
 - Works Everywhere: macOS, Linux, Windows (maybe lol), ARM64 – fully reproducible builds.
 - Battery-Included Examples: ready-to-run demos, benchmarks, fuzz and race tests.
 - Flexible, Not Fragile: swap or remove any piece without breaking the whole.
 
Tip: Run
magex helpright after cloning to see every command the template unlocks.
(delete this section once your project is initialized)
1) Clone or "Use this template"
git clone https://github.com/bsv-blockchain/go-template.git my-lib && cd my-lib... or click Use this template on GitHub and create a new repo.
2) Install MAGE-X build tool and run the installation script
go install github.com/mrz1836/mage-x/cmd/magex@latest
# Run the install script to customize the project for your organization
magex InstallTemplate owner=yourorg repo=yourprojectExample:
# For GitHub user "acme" creating a project called "awesome-api"
magex InstallTemplate owner=acme repo=awesome-api- 
Finds & replaces names across 70+ files
bsv-blockchain/go-template→yourorg/yourprojectgo-template→yourprojectbsv-blockchain→yourorg
 - 
Cleans up template artifacts
- Removes the default social-share image so you can add your own
 - Updates module paths in 
go.mod - Fixes all GitHub badges and links
 
 - 
Provides helpful feedback
- Shows exactly which files were modified
 - Gives you next steps to review and commit changes
 
 
Edit the highlighted files so they match your project:
LICENSE- Update the year and your name or organization
 
README.md- Remove the "remove-this-section" block in this file
 - Modify the "About" section to describe your library
 
.github/SECURITY.md- Update the security policy to match your project's needs
 
.github/FUNDING.yml- If you want to accept funding, add your funding links here
 
.goreleaser.yml- Modify settings for Slack, Discord, Twitter, or Reddit if you want to announce releases
 
CODEOWNERS- Adjust rules for code ownership if needed
 
Push your initial commit and run magex version:bump push=true bump=minor and the CI/CD pipeline will take it from there. 🚀
┌──────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                          │
│                GO-TEMPLATE – YOUR README STARTS RIGHT AFTER THIS BANNER                  │
│                                                                                          │
└──────────────────────────────────────────────────────────────────────────────────────────┘
                                         ⬇ ⬇ ⬇
go-template requires a supported release of Go.
go get -u github.com/bsv-blockchain/go-template- API Reference – Dive into the godocs at pkg.go.dev/github.com/bsv-blockchain/go-template
 - Usage Examples – Browse practical patterns either the examples directory or view the example functions
 - Benchmarks – Check the latest numbers in the benchmark results
 - Test Suite – Review both the unit tests and fuzz tests (powered by 
testify) 
Good to know:
go-templateships with zero runtime dependencies. The only external package we use istestifyandmagefile— and that's strictly for tests and dev.
Development Build Commands
Get the MAGE-X build tool for development:
go install github.com/mrz1836/mage-x/cmd/magex@latestView all build commands
magex helpRepository Features
- Continuous Integration on Autopilot with GitHub Actions – every push is built, tested, and reported in minutes.
 - Pull‑Request Flow That Merges Itself thanks to auto‑merge and hands‑free Dependabot auto‑merge.
 - One‑Command Builds powered by battle‑tested MAGE-X targets for linting, testing, releases, and more.
 - First‑Class Dependency Management using native Go Modules.
 - Uniform Code Style via gofumpt plus zero‑noise linting with golangci‑lint.
 - Confidence‑Boosting Tests with testify, the Go race detector, crystal‑clear HTML coverage snapshots, and automatic uploads to Codecov.
 - Hands‑Free Releases delivered by GoReleaser whenever you create a new Tag.
 - Relentless Dependency & Vulnerability Scans via Dependabot, Nancy and govulncheck.
 - Security Posture by Default with CodeQL, OpenSSF Scorecard and secret‑leak detection via gitleaks.
 - Automatic Syndication to pkg.go.dev on every release for instant godoc visibility.
 - Polished Community Experience using rich templates for Issues & PRs.
 - All the Right Meta Files (
LICENSE,CONTRIBUTING.md,CODE_OF_CONDUCT.md,SUPPORT.md,SECURITY.md) pre‑filled and ready. - Code Ownership clarified through a CODEOWNERS file, keeping reviews fast and focused.
 - Zero‑Noise Dev Environments with tuned editor settings (
.editorconfig) plus curated ignore files for VS Code, Docker, and Git. - Label Sync Magic: your repo labels stay in lock‑step with .github/labels.yml.
 - Friendly First PR Workflow – newcomers get a warm welcome thanks to a dedicated workflow.
 - Standards‑Compliant Docs adhering to the standard‑readme spec.
 - Instant Cloud Workspaces via Gitpod – spin up a fully configured dev environment with automatic linting and tests.
 - Out‑of‑the‑Box VS Code Happiness with a preconfigured Go workspace and 
.vscodefolder with all the right settings. - Optional Release Broadcasts to your community via Slack, Discord, or Twitter – plug in your webhook.
 - AI Compliance Playbook – machine‑readable guidelines (AGENTS.md, CLAUDE.md, .cursorrules, sweep.yaml) keep ChatGPT, Claude, Cursor & Sweep aligned with your repo's rules.
 - Go-Pre-commit System - High-performance Go-native pre-commit hooks with 17x faster execution—run the same formatting, linting, and tests before every commit, just like CI.
 - Zero Python Dependencies - Pure Go implementation with environment-based configuration via .env.base.
 - DevContainers for Instant Onboarding – Launch a ready-to-code environment in seconds with VS Code DevContainers and the included .devcontainer.json config.
 
Repository File Glossary
This glossary describes each tracked file in the repository and notes if it is required for GitHub or another external service.
| File Path | Description | Service | 
|---|---|---|
| .cursorrules | Rules for Cursor AI integrations | Cursor | 
| .devcontainer.json | VS Code dev or GitHub container configuration | VS Code & GitHub | 
| .dockerignore | Paths ignored by Docker builds | Docker | 
| .editorconfig | Editor configuration defaults | Editor | 
| .gitattributes | Git attributes and export settings | Git | 
| .github/.env.base | Shared environment variables for GitHub Actions | GitHub Actions | 
| .github/.env.custom | Custom environment variables for GitHub Actions | GitHub Actions | 
| .github/AGENTS.md | Contribution rules and guidelines | GitHub | 
| .github/CLAUDE.md | Claude agent instructions | Claude | 
| .github/CODEOWNERS | Code ownership declarations for GitHub | GitHub | 
| .github/CODE_OF_CONDUCT.md | Community behavior standards | GitHub | 
| .github/CODE_STANDARDS.md | Coding style guide | GitHub | 
| .github/CONTRIBUTING.md | How to contribute to the project | GitHub | 
| .github/FUNDING.yml | Funding links displayed by GitHub | GitHub | 
| .github/IMAGES/go-share-image.png | Social sharing image | GitHub | 
| .github/ISSUE_TEMPLATE/bug_report.yml | Issue template for bug reports | GitHub | 
| .github/ISSUE_TEMPLATE/feature_request.yml | Issue template for feature requests | GitHub | 
| .github/ISSUE_TEMPLATE/question.yml | Issue template for questions | GitHub | 
| .github/SECURITY.md | Security policy | GitHub | 
| .github/SUPPORT.md | Support guidelines | GitHub | 
| .github/dependabot.yml | Dependabot configuration | GitHub | 
| .github/labels.yml | Repository label definitions | GitHub | 
| .github/pull_request_template.md | Pull request description template | GitHub | 
| .github/sweep.yaml | Sweep AI configuration | Sweep AI | 
| .github/workflows/auto-merge-on-approval.yml | Workflow for automatic merges | GitHub Actions | 
| .github/workflows/codeql-analysis.yml | CodeQL security analysis workflow | GitHub Actions | 
| .github/workflows/dependabot-auto-merge.yml | Auto merge Dependabot PRs | GitHub Actions | 
| .github/workflows/fortress.yml | Fortress security & testing workflow | GitHub Actions | 
| .github/workflows/pull-request-management.yml | Pull request triage workflow | GitHub Actions | 
| .github/workflows/scorecard.yml | OpenSSF Scorecard workflow | GitHub Actions | 
| .github/workflows/stale.yml | Close stale issues and PRs | GitHub Actions | 
| .github/workflows/sync-labels.yml | Sync repository labels | GitHub Actions | 
| .gitignore | Files and directories Git should ignore | Git | 
| .gitpod.yml | Gitpod workspace configuration | Gitpod | 
| .golangci.json | GolangCI-Lint configuration | GolangCI-Lint | 
| .goreleaser.yml | GoReleaser configuration for release automation | GoReleaser | 
| .prettierignore | Paths ignored by Prettier formatting | Prettier | 
| .prettierrc.yml | Prettier configuration file | Prettier | 
| .vscode/extensions.json | Recommended VS Code extensions | VS Code | 
| .vscode/launch.json | VS Code debugging configuration | VS Code | 
| .vscode/settings.json | VS Code workspace settings | VS Code | 
| .vscode/tasks.json | VS Code tasks configuration | VS Code | 
| CITATION.cff | Citation metadata recognized by GitHub | GitHub | 
| Dockerfile | Docker image build instructions | Docker | 
| LICENSE | Project license | Yours! | 
| README.md | Project overview and usage | Yours! | 
| codecov.yml | Codecov upload configuration | Codecov | 
| examples/example.go | Example usage of the library | None | 
| go.mod | Go module definition | Go | 
| go.sum | Dependency checksums generated by Go | Go | 
| magefile.go | Magefile with MAGE-X targets | MAGE-X | 
| template.go | Main package source code | Yours! | 
| template_benchmark_test.go | Go benchmark tests | Go test | 
| template_example_test.go | Example tests for documentation | Go test | 
| template_fuzz_test.go | Go fuzz tests | Go test | 
| template_test.go | Unit tests | Go test | 
Library Deployment
This project uses goreleaser for streamlined binary and library deployment to GitHub. To get started, install it via:
brew install goreleaserThe release process is defined in the .goreleaser.yml configuration file.
Then create and push a new Git tag using:
magex version:bump push=true bump=patch branch=masterThis process ensures consistent, repeatable releases with properly versioned artifacts and citation metadata.
Pre-commit Hooks
Set up the Go-Pre-commit System to run the same formatting, linting, and tests defined in AGENTS.md before every commit:
go install github.com/mrz1836/go-pre-commit/cmd/go-pre-commit@latest
go-pre-commit installThe system is configured via .env.base and can be customized using also using .env.custom and provides 17x faster execution than traditional Python-based pre-commit hooks. See the complete documentation for details.
GitHub Workflows
All GitHub Actions workflows in this repository are powered by a single configuration files – your one-stop shop for tweaking CI/CD behavior without touching a single YAML file! 🎯
Configuration Files:
- .env.base – Default configuration that works for most Go projects
 - .env.custom – Optional project-specific overrides
 
This magical file controls everything from:
- ⚙️ Go version matrix (test on multiple versions or just one)
 - 🏃 Runner selection (Ubuntu or macOS, your wallet decides)
 - 🔬 Feature toggles (coverage, fuzzing, linting, race detection, benchmarks)
 - 🛡️ Security tool versions (gitleaks, nancy, govulncheck)
 - 🤖 Auto-merge behaviors (how aggressive should the bots be?)
 - 🏷️ PR management rules (size labels, auto-assignment, welcome messages)
 
| Workflow Name | Description | 
|---|---|
| auto-merge-on-approval.yml | Automatically merges PRs after approval and all required checks, following strict rules. | 
| codeql-analysis.yml | Analyzes code for security vulnerabilities using GitHub CodeQL. | 
| dependabot-auto-merge.yml | Automatically merges Dependabot PRs that meet all requirements. | 
| fortress.yml | Runs the GoFortress security and testing workflow, including linting, testing, releasing, and vulnerability checks. | 
| pull-request-management.yml | Labels PRs by branch prefix, assigns a default user if none is assigned, and welcomes new contributors with a comment. | 
| scorecard.yml | Runs OpenSSF Scorecard to assess supply chain security. | 
| stale.yml | Warns about (and optionally closes) inactive issues and PRs on a schedule or manual trigger. | 
| sync-labels.yml | Keeps GitHub labels in sync with the declarative manifest at .github/labels.yml. | 
Updating Dependencies
To update all dependencies (Go modules, linters, and related tools), run:
magex deps:updateThis command ensures all dependencies are brought up to date in a single step, including Go modules and any tools managed by MAGE-X. It is the recommended way to keep your development environment and CI in sync with the latest versions.
All unit tests and examples run via GitHub Actions and use Go version 1.24.x. View the configuration file.
Run all tests (fast):
magex testRun all tests with race detector (slower):
magex test:raceRun the Go benchmarks:
magex bench| Benchmark | Iterations | ns/op | B/op | allocs/op | 
|---|---|---|---|---|
| Greet | 21,179,739 | 56.59 | 40 | 2 | 
These benchmarks reflect fast, allocation-free lookups for most retrieval functions, ensuring optimal performance in production environments. Performance benchmarks for the core functions in this library, executed on an Apple M1 Max (ARM64).
Read more about this Go project's code standards.
This project documents expectations for AI assistants using a few dedicated files:
- AGENTS.md — canonical rules for coding style, workflows, and pull requests used by Codex.
 - CLAUDE.md — quick checklist for the Claude agent.
 - .cursorrules — machine-readable subset of the policies for Cursor and similar tools.
 - sweep.yaml — rules for Sweep, a tool for code review and pull request management.
 
Edit AGENTS.md first when adjusting these policies, and keep the other files in sync within the same pull request.
![]()  | 
|---|
| MrZ | 
View the contributing guidelines and please follow the code of conduct.
All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬.
