Skip to content

Commit

Permalink
use go_run_tool to run goimports
Browse files Browse the repository at this point in the history
  • Loading branch information
dprotaso committed Jun 8, 2020
1 parent 926681d commit 43644de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
17 changes: 4 additions & 13 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

set -o pipefail

source $(dirname $0)/../scripts/test-infra/library.sh

source_dirs="cmd pkg test lib"

# Store for later
Expand Down Expand Up @@ -112,19 +114,8 @@ go_fmt() {

source_format() {
set +e
which goimports >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "✋ No 'goimports' found. Please use"
echo "✋ go install golang.org/x/tools/cmd/goimports"
echo "✋ to enable import cleanup. Import cleanup skipped."

# Run go fmt instead
go_fmt
else
echo "🧽 ${X}Format"
goimports -w $(echo $source_dirs)
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
fi
run_go_tool golang.org/x/tools/cmd/goimports goimports -w $(echo $source_dirs)
find $(echo $source_dirs) -name "*.go" -print0 | xargs -0 gofmt -s -w
set -e
}

Expand Down
3 changes: 0 additions & 3 deletions hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ set -o pipefail

source $(dirname $0)/../scripts/test-infra/library.sh

# Needed later
go install golang.org/x/tools/cmd/goimports

"${REPO_ROOT_DIR}"/hack/build.sh --codegen
if output="$(git status --porcelain)" && [ -z "$output" ]; then
echo "${REPO_ROOT_DIR} is up to date."
Expand Down

0 comments on commit 43644de

Please sign in to comment.