diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-10-26 22:53:43 -0300 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 0c3a2cd0d40973d2b93e2a158c68264b4bebfa2f (patch) | |
tree | dc861d0f641aa77f74447b928d5cbc302105e584 /.githooks/pre-commit | |
parent | b97e0403c8f0be0bf415e537981763495ae0b783 (diff) |
git hooks, readme section on dev
Diffstat (limited to '.githooks/pre-commit')
-rwxr-xr-x | .githooks/pre-commit | 12 |
1 files changed, 12 insertions, 0 deletions
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 |