Skip to content

tabmadi/go-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸš€ Go Template

Go Version License Go Report Card mise lefthook golangci-lint act

This is a modern GitHub template repository for Go projects. Use this template to create a new Go application with a standardized structure, automated tooling, and best practices built-in.

✨ Features

  • ⚑ High Performance: Optimized build configuration with cross-compilation support and size optimization flags.
  • 🐹 Go: Modern Go version with module support and following Effective Go guidelines.
  • πŸ”§ Modern Tooling: Pre-configured with mise for tool and task management, golangci-lint for code quality, * Lefthook* for Git hooks, and act for local CI simulation.
  • πŸ“ Structured: Adopts the Standard Go Project Layout for a clean and organized codebase.

πŸš€ Quick Start

Prerequisites

  • mise - A multi-language version manager and task runner.
  • Go - Programming language (managed by mise).
  • act - Run your GitHub Actions locally.

Installation

  1. Clone the repository:

    git clone https://github.com/TheRealZurvan/go-template.git
    cd go-template
  2. Setup environment:

    # Install all required tools using mise
    mise install
    
    # Set up the project (download dependencies and install git hooks)
    mise run setup

πŸƒβ€β™‚οΈ Usage

Instructions on how to run the project.

# Run the application directly (development)
mise run run

# Build and run the production binary
mise run build
./bin/app

πŸ› οΈ Development

Available Scripts

Script Description
mise run setup Set up the project dependencies
mise run clean Clean build artifacts
mise run format Format the code and auto-fix linting issues
mise run lint Run linter (golangci-lint)
mise run test Run tests
mise run build Build the project
mise run run Run the application
mise run act Simulate CI locally with act

🧹 Code Quality

We use golangci-lint for linting and formatting with 40+ linters:

# Check for linting issues
mise run lint

# Auto-fix linting issues and format code
mise run format

πŸͺ Git Hooks & Conventional Commits

This project uses Lefthook for Git hooks and follows Conventional Commits.

  • Pre-commit: Formats code and runs golangci-lint.
  • Commit-msg: Validates commit message format.
  • Pre-push: Final lint and test checks.

Conventional Commits Example:

# βœ… Valid commit messages
git commit -m "feat: add user authentication"
git commit -m "fix: resolve memory leak"

πŸ“ Project Structure

.
β”œβ”€β”€ cmd/                # Application entry points
β”‚   └── app/            # Main application
β”œβ”€β”€ internal/           # Private code (business logic, config)
β”œβ”€β”€ scripts/            # Helper scripts
β”œβ”€β”€ bin/                # Built binaries (created by build)
β”œβ”€β”€ .github/            # GitHub Actions and act configuration
β”œβ”€β”€ mise.toml           # Mise configuration
└── README.md           # You are here! πŸ“

βš™οΈ Configuration

File Purpose Key Features
mise.toml Mise task runner Task definitions, environment variables
.lefthook.yml Git hooks Pre-commit linting, automated quality checks
.golangci.yml Linting configuration 40+ linters, formatting rules, quality checks
go.mod Go module definition Module path, Go version requirements
.tool-versions Tool version manager Consistent versions for mise

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (Conventional Commits)
  4. Push to the branch
  5. Open a Pull Request

πŸ”’ Security

Please see SECURITY.md for our security policy and how to report security vulnerabilities.

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Go for the amazing programming language
  • golangci-lint for comprehensive code quality checks
  • mise for tool and task management
  • Lefthook for fast and reliable Git hooks
  • act for local CI simulation

Happy coding! πŸŽ‰ If you find this template useful, please give it a ⭐️

About

A basic GitHub repository template for Go projects

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors