Skip to content

Commit

Permalink
Factor golint validation into a script
Browse files Browse the repository at this point in the history
This script (scripts/golint.sh) handily exempts vendored and generated
files.

Sample usage:

* “scripts/goimports.sh -d -e” → show full diff
* “scripts/goimports.sh -w” → fix files in-place
  • Loading branch information
Eugene Kim committed Jan 25, 2019
1 parent 97809dd commit bb3d29f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 8 additions & 0 deletions scripts/golint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
unset -v progdir
case "${0}" in
*/*) progdir="${0%/*}";;
*) progdir=.;;
esac
"${progdir}/list_harmony_go_files.sh" | "${progdir}/dirnames.sh" | \
sort -u -t/ | xargs golint "$@"
8 changes: 2 additions & 6 deletions scripts/travis_checker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

unset -v ok tmpdir go_dirs goimports_output golint_output progdir
unset -v ok tmpdir goimports_output golint_output progdir
ok=true

case "${0}" in
Expand All @@ -14,10 +14,6 @@ tmpdir=
trap 'case "${tmpdir}" in ?*) rm -rf "${tmpdir}";; esac' EXIT
tmpdir=$(mktemp -d)


go_dirs="${tmpdir}/go_dirs.txt"
"${progdir}/list_harmony_go_files.sh" | "${progdir}/dirnames.sh" | sort -u -t/ > "${go_dirs}"

echo "Running go test..."
if go test -v -count=1 ./...
then
Expand All @@ -29,7 +25,7 @@ fi

echo "Running golint..."
golint_output="${tmpdir}/golint_output.txt"
if xargs golint -set_exit_status < "${go_dirs}" > "${golint_output}" 2>&1
if "${progdir}/golint.sh" -set_exit_status > "${golint_output}" 2>&1
then
echo "golint passed."
else
Expand Down

0 comments on commit bb3d29f

Please sign in to comment.