aboutsummaryrefslogtreecommitdiff
path: root/.githooks
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-10-26 22:53:43 -0300
committerFChannel <>2022-06-19 12:53:29 -0700
commit0c3a2cd0d40973d2b93e2a158c68264b4bebfa2f (patch)
treedc861d0f641aa77f74447b928d5cbc302105e584 /.githooks
parentb97e0403c8f0be0bf415e537981763495ae0b783 (diff)
git hooks, readme section on dev
Diffstat (limited to '.githooks')
-rwxr-xr-x.githooks/pre-commit12
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