Skip to content

Commit

Permalink
Setup validate-golint
Browse files Browse the repository at this point in the history
- Add a validate-lint target (and script/validate-lint that does the
  job)
- Add the first package that is covered by it : version.

Related to docker#14
  • Loading branch information
vdemeester committed Aug 13, 2015
1 parent 161d9b8 commit a16868e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN go get github.com/mitchellh/gox
RUN go get github.com/aktau/github-release
RUN go get github.com/tools/godep
RUN go get golang.org/x/tools/cmd/cover
RUN go get github.com/golang/lint/golint

# Which docker version to test on
ENV DOCKER_VERSION 1.7.1
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ validate-dco: build
validate-gofmt: build
$(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh validate-gofmt

validate: validate-dco validate-gofmt
validate-lint: build
$(DOCKER_RUN_LIBCOMPOSE) ./script/make.sh validate-lint

validate: validate-dco validate-gofmt validate-lint

shell: build
$(DOCKER_RUN_LIBCOMPOSE) bash
Expand Down
35 changes: 35 additions & 0 deletions script/validate-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# We will eventually get to the point when packages should be the complete list
# of subpackages, vendoring excluded, as given by:
#
# packages=( $(go list ./... 2> /dev/null | grep -vE "^github.com/docker/docker/vendor" || true ) )

packages=(
version
)

errors=()
for p in "${packages[@]}"; do
# Run golint on package/*.go file explicitly to validate all go files
# and not just the ones for the current platform.
failedLint=$(golint "$p"/*.go)
if [ "$failedLint" ]; then
errors+=( "$failedLint" )
fi
done

if [ ${#errors[@]} -eq 0 ]; then
echo 'Congratulations! All Go source files have been linted.'
else
{
echo "Errors from golint:"
for err in "${errors[@]}"; do
echo "$err"
done
echo
echo 'Please fix the above errors. You can test via "golint" and commit the result.'
echo
} >&2
false
fi

0 comments on commit a16868e

Please sign in to comment.