-
Notifications
You must be signed in to change notification settings - Fork 1.5k
hack/go-fmt: Make it easy to auto-format Go #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We've had some gofmt issues sneak in recently [1]. We want to catch that sort of thing in CI, instead of finding out about it later. This commit uses the script from openshift/installer@94a2a8ca (hack/go-fmt: Make it easy to auto-format Go, 2018-08-24, openshift/installer#173) to automate that check. [1]: openshift/installer@8f415b9#commitcomment-30284820
|
e2e-aws has exhausted its resources: |
So users and CI tooling can keep our Go clean :). The find call avoids formatting .build/* (Bazel output) and vendor/* (controlled upstream), because gofmt has no special vendor/ handling built in [1]. Formatting our Go and then using 'git diff' to show the changes (and error if there were any) makes it easy for: * CI to see if there were issues (because of the exit code). * Users to see the required changes in the CI logs (because of the output diff). [1]: golang/go#22173 (comment)
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wking, yifan-gu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
This died We've seen that before (e.g. here). But I'll wait until later to kick this off again, because we've had a few e2e-aws resource-exhaustion issues recently. |
|
/retest |
Catching up with 4e92db8 (Merge pull request openshift#120 from staebler/asset_graph_engine, 2018-08-24). * Drop the go-lint comment from go-fmt.sh. I'd accidentally copy/pasted this over in 87b3e17 (hack/go-fmt: Make it easy to auto-format Go, 2018-08-24, openshift#173). * Suggest users run go-lint over pkg/... as well. * Simplify the 'go vet' invocation. The code I'm removing is from eb71c8d (Added go-vet shell script, 2018-08-06, openshift#110). The Travis config it replaced was removed in 1765e93 (.travis.yml: Prune moved-to-Prow tf-lint, etc., 2018-08-14, openshift#123), but was just running: go vet ./installer/... inside the container. So I don't think we need the directory changing or moving here. And we should certainly be able to cover the test from a single container, instead of launch a new container for each requested directory (at least as long as the requested directories are under $PWD, and the old script required that anyway).
So users and CI tooling can keep our Go clean :).
The
findcall avoids formatting.build/*(Bazel output) andvendor/*(controlled upstream), becausegofmthas no specialvendor/handling built in.Formatting our Go and then using
git diffto show the changes (and error if there were any) makes it easy for: