Skip to content

Commit a26a0ff

Browse files
authored
Merge pull request #9 from Bahjat/adds-optional-config-file-golangci-lint
Adds optional config file golangci lint
2 parents cc37787 + 973560b commit a26a0ff

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
# pre-commit-golang
2+
23
Golang pre-commit hooks for http://pre-commit.com/
4+
35
## install
6+
47
you need first to install [pre-commit](https://pre-commit.com/#install)
8+
59
```
610
brew install pre-commit
711
```
12+
813
install pre-commit into your git repo
14+
915
```
1016
pre-commit install
1117
```
18+
1219
## Usage
20+
1321
Add a file named `.pre-commit-config.yaml` into the root directory of your repository
22+
1423
```yaml
1524
repos:
1625
- repo: https://github.com/Bahjat/pre-commit-golang
17-
rev: v1.0.0
26+
rev: v1.0.1
1827
hooks:
1928
- id: go-fmt-import
2029
- id: go-vet
@@ -24,20 +33,21 @@ repos:
2433
- id: go-err-check # requires github.com/kisielk/errcheck
2534
- id: go-static-check # install https://staticcheck.io/docs/
2635
- id: golangci-lint # requires github.com/golangci/golangci-lint
36+
args: [--config=.github/linters/.golangci.yml] # optional
2737
```
38+
2839
## Contributing
40+
2941
- Fork it
3042
- Create your feature branch `git checkout -b my-new-feature`
3143
- Commit your changes `git commit -am 'Add some feature'`
3244
- Push to the branch `git push origin my-new-feature`
3345
- Create new Pull Request
3446

3547
## Credits
36-
This repo is inspired by [dnephin/pre-commit-golang](https://github.com/dnephin/pre-commit-golang)
3748

38-
## Contributors
39-
40-
![Contributors](https://readme-contributors.now.sh/Bahjat/pre-commit-golang?extension=jpg&width=300)
49+
This repo is inspired by [dnephin/pre-commit-golang](https://github.com/dnephin/pre-commit-golang)
4150

4251
## Finally
52+
4353
If you like this hooks please give a star

run-golangci-lint.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/bin/sh
22

3-
ERRS=$(golangci-lint run --new-from-rev="$(git rev-parse HEAD)")
3+
CONFIG_FILE="$1"
4+
5+
if ! command -v golangci-lint 2>&1 /dev/null
6+
then
7+
echo "golangci-lint could not be found"
8+
exit
9+
fi
10+
11+
ERRS=$(golangci-lint run --new-from-rev="$(git rev-parse HEAD)" "$CONFIG_FILE")
412

513
if [ -n "${ERRS}" ]; then
614
echo "${ERRS}"

0 commit comments

Comments
 (0)