Skip to content

Commit 01ba49a

Browse files
committed
[BUILD] Move golang linter into a script
We can reuse the array definition to perform both the go-vet and go-import operations. This also sets the stage for running the linter within a docker instance later in the series. Change-Id: I5fcda6c441cfef49837b855a2d6bb2cc3d300847 Signed-off-by: Greg Haskins <[email protected]>
1 parent 2471f9a commit 01ba49a

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

Makefile

+1-9
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,7 @@ behave: behave-deps
104104

105105
linter: gotools
106106
@echo "LINT: Running code checks.."
107-
@echo "Running go vet"
108-
go vet ./core/...
109-
go vet ./events/...
110-
go vet ./examples/...
111-
go vet ./peer/...
112-
go vet ./protos/...
113-
go vet ./orderer/...
114-
@echo "Running goimports"
115-
@./scripts/goimports.sh
107+
@./scripts/golinter.sh
116108

117109
# We (re)build protoc-gen-go from within docker context so that
118110
# we may later inject the binary into a different docker environment

scripts/goimports.sh

-16
This file was deleted.

scripts/golinter.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer")
6+
7+
for i in "${arr[@]}"
8+
do
9+
echo "Checking $i"
10+
go vet $i/...
11+
OUTPUT="$(goimports -srcdir $GOPATH/src/github.com/hyperledger/fabric -l $i)"
12+
if [[ $OUTPUT ]]; then
13+
echo "The following files contain goimports errors"
14+
echo $OUTPUT
15+
echo "The goimports command must be run for these files"
16+
exit 1
17+
fi
18+
done

0 commit comments

Comments
 (0)