From 0c3a2cd0d40973d2b93e2a158c68264b4bebfa2f Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Tue, 26 Oct 2021 22:53:43 -0300 Subject: git hooks, readme section on dev --- .githooks/pre-commit | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 .githooks/pre-commit (limited to '.githooks/pre-commit') diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..95fbb20 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh + +# This hook formats every Go file with `go fmt` before committing them. +# It helps to enforce the Go style guide for those who forget to format their code properly. + +STAGED="$(git diff --cached --name-only -- '*.go')" +if [ -n "$STAGED" ]; then + for file in $STAGED; do + go fmt "$file" + git add "$file" + done +fi -- cgit v1.2.3