Use go_sdk gofmt instead of goimports
Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
parent
86ef1db811
commit
302e16ace8
@ -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",
|
||||
|
||||
@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@ -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"],
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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'"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user