Skip to content

Commit

Permalink
Merge pull request #375 from snf1k/golangci-lint
Browse files Browse the repository at this point in the history
Add golangci-lint
  • Loading branch information
domenkozar authored Nov 25, 2023
2 parents e558068 + 0067c7c commit e5ee5c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ use nix

- gofmt: Runs `go fmt`
- gotest: Runs `go test`
- [golangci-lint](https://golangci-lint.run/)
- [govet](https://pkg.go.dev/cmd/vet)
- [revive](https://github.com/mgechev/revive)
- [staticcheck](https://github.com/dominikh/go-tools)
Expand Down
19 changes: 19 additions & 0 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2208,5 +2208,24 @@ in
description = "Runs the git-annex hook for large file support";
entry = "${tools.git-annex}/bin/git-annex pre-commit";
};

golangci-lint = {
name = "golangci-lint";
description = "Fast linters runner for Go.";
entry =
let
script = pkgs.writeShellScript "precommit-golangci-lint" ''
set -e
for dir in $(echo "$@" | xargs -n1 dirname | sort -u); do
${tools.golangci-lint}/bin/golangci-lint run ./"$dir"
done
'';
in
builtins.toString script;
files = "\\.go$";
# to avoid multiple invocations of the same directory input, provide
# all file names in a single run.
require_serial = true;
};
};
}
2 changes: 2 additions & 0 deletions nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
, writeText
, go
, go-tools
, golangci-lint
, revive ? null
}:

Expand Down Expand Up @@ -98,6 +99,7 @@ in
git-annex
go
go-tools
golangci-lint
gptcommit
hadolint
hindent
Expand Down

0 comments on commit e5ee5c5

Please sign in to comment.