Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Created April 6, 2024 22:32
Show Gist options
  • Save yordanoweb/12cf297e35d244d826a1852183bffeee to your computer and use it in GitHub Desktop.
Save yordanoweb/12cf297e35d244d826a1852183bffeee to your computer and use it in GitHub Desktop.
Prepare Golang project for pre-commit

Steps to prepare a Golang project for pre-commit stuff

sudo pamac install pre-commit
sudo npm install -g @commitlint/cli @commitlint/config-conventional
vi /root/golang/project/commitlint.config.js
// /root/golang/project/commitlint.config.js

module.exports = {
    extends: ['@commitlint/config-conventional']
};
# /root/golang/project/.pre-commit-config.yaml
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.3.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
  - repo: https://github.com/dnephin/pre-commit-golang
    rev: v0.5.0
    hooks:
      - id: go-fmt
      - id: go-imports
      - id: no-go-testing
      - id: golangci-lint
  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v8.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ['@commitlint/config-conventional']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment