Formatting code with gofmt
Description
Formatting code with gofmt
Related issues/PRs
Todos
- [ ] Tests
- [ ] Documentation
- [ ] Release note
Release Note
Formatting code with gofmt
Reminder for the reviewer
Make sure that this PR has the correct labels and milestone set.
Every PR needs one docs-* label.
docs-pr-required: This change requires a change to the documentation that has not been completed yet.docs-completed: This change has all necessary documentation completed.docs-not-required: This change has no user-facing impact and requires no docs.
Every PR needs one release-note-* label.
release-note-required: This PR has user-facing changes. Most PRs should have this label.release-note-not-required: This PR has no user-facing changes.
Other optional labels:
cherry-pick-candidate: This PR should be cherry-picked to an earlier release. For bug fixes only.needs-operator-pr: This PR is related to install and requires a corresponding change to the operator.
@cuishuang We already have a mechanism for formatting in this repo, with make fix. It uses goimports, and I've just run it locally to see if it makes the same changes as in this PR, and it doesn't.
Your changes look good (and I also see that gopls recommends them), but instead of just committing them we need to work out why our make fix and goimports usage doesn't make the same changes. I'm wondering if we are using an excessively old versoin of goimports in our go-build container.
It seems we're already using the latest goimports (v0.25.0), so it's puzzling why that isn't already making these changes.
It seems we're already using the latest goimports (v0.25.0), so it's puzzling why that isn't already making these changes.
Yes, it is confusing. goimports is a stricter way of formatting than gofmt
@caseydavenport Would you happen to know why goimports doesn't make these changes for us?
I also ran goimports locally and it did not produce these changes. I am not sure why. The changes look reasonable to me, but I am a bit confused by why goimports doesn't do it for me.
Looks like @cuishuang ran gofmt -s for "simplify". goimports doesn't support -s so we don't use it.
/sem-approve