Skip to content

Commit adbc2af

Browse files
authored
feat: Add gofumpt (#20)
Signed-off-by: Bryan Hundven <[email protected]>
1 parent 514f70a commit adbc2af

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
language: 'script'
88
description: "Runs `gofmt`. Requires golang: https://go.dev/doc/install"
99
pass_filenames: true
10+
- id: go-fumpt
11+
name: 'gofumpt'
12+
entry: pre-commit-hooks/go-fumpt.sh
13+
types: [go]
14+
exclude: '(^|/)vendor/'
15+
language: 'script'
16+
description: "Runs `gofumpt`. Requires gofumpt: https://github.com/mvdan/gofumpt" # yamllint disable-line rule:line-length
17+
pass_filenames: true
1018
- id: go-imports
1119
name: 'goimports'
1220
entry: pre-commit-hooks/go-imports.sh

pre-commit-hooks/go-fumpt.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
# vi: ts=2:sw=2:et
3+
# vim: ft=bash
4+
5+
set -euo pipefail
6+
7+
if ! command -v gofumpt &> /dev/null
8+
then
9+
echo "gofumpt is not installed or is not in the current PATH" >&2
10+
echo "Find out more at: https://github.com/mvdan/gofumpt" >&2
11+
exit 1
12+
fi
13+
14+
output="$(gofumpt -l -w "$@")"
15+
echo "${output}"
16+
[[ -z "${output}" ]]

0 commit comments

Comments
 (0)