Skip to content

Commit

Permalink
[BUILD] Move golang linter into a script
Browse files Browse the repository at this point in the history
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 <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Nov 7, 2016
1 parent 2471f9a commit 01ba49a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,7 @@ behave: behave-deps

linter: gotools
@echo "LINT: Running code checks.."
@echo "Running go vet"
go vet ./core/...
go vet ./events/...
go vet ./examples/...
go vet ./peer/...
go vet ./protos/...
go vet ./orderer/...
@echo "Running goimports"
@./scripts/goimports.sh
@./scripts/golinter.sh

# We (re)build protoc-gen-go from within docker context so that
# we may later inject the binary into a different docker environment
Expand Down
16 changes: 0 additions & 16 deletions scripts/goimports.sh

This file was deleted.

18 changes: 18 additions & 0 deletions scripts/golinter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer")

for i in "${arr[@]}"
do
echo "Checking $i"
go vet $i/...
OUTPUT="$(goimports -srcdir $GOPATH/src/github.com/hyperledger/fabric -l $i)"
if [[ $OUTPUT ]]; then
echo "The following files contain goimports errors"
echo $OUTPUT
echo "The goimports command must be run for these files"
exit 1
fi
done

0 comments on commit 01ba49a

Please sign in to comment.