Files
clio/pre-commit-hooks/run-go-fmt.sh
Ayaz Salikhov 424af5dfe0 style: Apply go fmt to go code (#2046)
~I will add pre-commit hook later if I find a good one~

Found a nice repo, but it is no longer maintained:
https://github.com/dnephin/pre-commit-golang
So, I implemented the check as a local hook.
2025-04-28 16:04:50 +01:00

15 lines
294 B
Bash
Executable File

#!/usr/bin/env bash
#
# Capture and print stdout, since gofmt doesn't use proper exit codes
#
set -e -o pipefail
if ! command -v gofmt &> /dev/null ; then
echo "gofmt not installed or available in the PATH" >&2
exit 1
fi
output="$(gofmt -l -w "$@")"
echo "$output"
[[ -z "$output" ]]