diff --git a/WORKSPACE b/WORKSPACE index 1b40a2a77..2729ce7b6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -35,15 +35,6 @@ load( gazelle_dependencies() -## Load go tools repo for goimports -# This the git commit hash **must** be updated when the r -go_repository( - name = "org_golang_x_tools", - commit = "156d532d4f67148ceab07c3b59ed7fa13bdbf00c", - remote = "https://github.com/golang/tools.git", - importpath = "golang.org/x/tools", -) - ## Load kubernetes repo-infra for tools like kazel git_repository( name = "io_kubernetes_build", diff --git a/hack/BUILD.bazel b/hack/BUILD.bazel index c3be45e45..8acbbe854 100644 --- a/hack/BUILD.bazel +++ b/hack/BUILD.bazel @@ -144,7 +144,7 @@ sh_binary( name = "update-gofmt", srcs = ["update-gofmt.sh"], data = [ - "//hack/bin:goimports", + "//hack/bin:gofmt", ], ) @@ -153,7 +153,7 @@ sh_test( srcs = ["verify-gofmt.sh"], data = [ "//:all-srcs", - "//hack/bin:goimports", + "//hack/bin:gofmt", ], ) diff --git a/hack/bin/BUILD.bazel b/hack/bin/BUILD.bazel index 159918f51..020c7cc8a 100644 --- a/hack/bin/BUILD.bazel +++ b/hack/bin/BUILD.bazel @@ -48,9 +48,9 @@ genrule( ) genrule( - name = "fetch_goimports", - srcs = ["@org_golang_x_tools//cmd/goimports"], - outs = ["goimports"], + name = "fetch_gofmt", + srcs = ["@go_sdk//:bin/gofmt"], + outs = ["gofmt"], cmd = "cp $(SRCS) $@", visibility = ["//visibility:public"], ) diff --git a/hack/update-gofmt.sh b/hack/update-gofmt.sh index cccde58c0..bc4e767e4 100755 --- a/hack/update-gofmt.sh +++ b/hack/update-gofmt.sh @@ -24,5 +24,5 @@ runfiles="$(pwd)" export PATH="${runfiles}/hack/bin:${PATH}" cd "${REPO_ROOT}" -echo "+++ Running goimports" -find . -type f -name '*.go' | grep -v 'vendor/' | xargs goimports -w +echo "+++ Running gofmt" +find . -type f -name '*.go' | grep -v 'vendor/' | xargs gofmt -s -w diff --git a/hack/verify-gofmt.sh b/hack/verify-gofmt.sh index ae0b8edf8..66ddd2941 100755 --- a/hack/verify-gofmt.sh +++ b/hack/verify-gofmt.sh @@ -36,8 +36,8 @@ mkdir -p "$(dirname ${TMP_DIFFROOT})" ln -s "$(pwd)" "${TMP_DIFFROOT}" cd "${TMP_DIFFROOT}" -echo "+++ Running goimports" -output=$(find . -name '*.go' | grep -v 'vendor/' | xargs goimports -d -e) +echo "+++ Running gofmt" +output=$(find . -name '*.go' | grep -v 'vendor/' | xargs gofmt -s -d) if [ ! -z "${output}" ]; then echo "${output}" echo "Please run 'bazel run //hack:update-gofmt'"