From d0d62cd624f3ce3f3d23645fdb36c03eb721f912 Mon Sep 17 00:00:00 2001 From: Gavin C Date: Thu, 20 Jan 2022 14:19:33 +0000 Subject: [PATCH] Change the way `go fmt` is executed Since `$@` contains a filtered list of all `*.go` files that are staged for the commit, calling `go fmt` on them individually stops the error being thrown when trying to run `go fmt` against a subdirectory, from a directory which does not contain a `go.mod` file --- hooks/gofmt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/gofmt.sh b/hooks/gofmt.sh index 722d908e..6d40d959 100755 --- a/hooks/gofmt.sh +++ b/hooks/gofmt.sh @@ -9,5 +9,5 @@ export PATH=$PATH:/usr/local/bin for file in "$@"; do - go fmt "./$(dirname "$file")" + go fmt "$file" done