mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add new goimport_pass
Signed-off-by: Hanning Lin <liam.hanninglin@outlook.com>
This commit is contained in:
6
Makefile
6
Makefile
@@ -45,7 +45,7 @@ fuzz:
|
||||
|
||||
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
|
||||
verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck \
|
||||
verify-shellws verify-proto-annotations verify-genproto
|
||||
verify-shellws verify-proto-annotations verify-genproto verify-goimport
|
||||
fix: fix-bom fix-lint
|
||||
./scripts/fix.sh
|
||||
|
||||
@@ -109,6 +109,10 @@ verify-proto-annotations:
|
||||
verify-genproto:
|
||||
PASSES="genproto" ./scripts/test.sh
|
||||
|
||||
.PHONY: verify-goimport
|
||||
verify-goimport:
|
||||
PASSES="goimport" ./scripts/test.sh
|
||||
|
||||
# Failpoints
|
||||
|
||||
GOFAIL_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} go.etcd.io/gofail)
|
||||
|
||||
@@ -632,6 +632,21 @@ function genproto_pass {
|
||||
"${ETCD_ROOT_DIR}/scripts/verify_genproto.sh"
|
||||
}
|
||||
|
||||
function goimport_for_module {
|
||||
GOFILES=$(run go list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
|
||||
TESTGOFILES=$(run go list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
|
||||
cd "${ETCD_ROOT_DIR}/tools/mod"
|
||||
FILESNEEDSFIX=$(echo "${GOFILES}" "${TESTGOFILES}" | grep -v '.gw.go' | grep -v '.pb.go' | xargs -n 100 go run golang.org/x/tools/cmd/goimports -l -local go.etcd.io)
|
||||
if [ -n "$FILESNEEDSFIX" ]; then
|
||||
log_error -e "the following files are not sync with 'goimports'. run 'make fix'\\n$FILESNEEDSFIX"
|
||||
return 255
|
||||
fi
|
||||
}
|
||||
|
||||
function goimport_pass {
|
||||
run_for_modules goimport_for_module
|
||||
}
|
||||
|
||||
########### MAIN ###############################################################
|
||||
|
||||
function run_pass {
|
||||
|
||||
Reference in New Issue
Block a user