Format all code according to `gofmt` standard, add Makefile rule

CSP Request Details

None

CSP Rejection Details

None

CSP Approved

None

Description

The Go language and its community strongly encourage you to format your code according to the One True Style — indent using tab characters, opening brace on the same line as the conditional, etc. The language’s tooling makes it very easy to do this: go fmt ./... will rewrite all your project’s source files in place.

I’ve resisted doing this because there are some things about the standard formatting that I dislike: most important, that it prohibits multiple blank lines between functions. But I’ve come to the conclusion that adhering to the standard is more important than preserving this preference. The value proposition of gofmt is “never think about formatting again”, and I think that trade-off is worth making.

Environment

None

Potential Workaround

None

Checklist

hide

Activity

Show:

Mike Taylor October 23, 2024 at 5:42 PM

See for the non-whitespace changes.

Mike Taylor October 23, 2024 at 5:38 PM

I have verified that all the changes gofmt wants to make to my code fall into these categories:

  • Loss of multiple blank lines between functions.

  • Insertion and removal of whitespace in certain syntactic forms, e.g. removing the spaces inside the braces in foliogo.RequestParams{Token: token} and around the operator in baseUrl + test.path.

  • Removal of unnecessary parentheses around the argument of range.

  • Removal of unnecessary parentheses around single return-type specifiers.

  • Breaking inline structure constants like { method = "POST" } across multiple lines.

I’m not crazy about the first and last of these, but I can live with them. The others are straight-up improvements.

Done

Details

Assignee

Reporter

Priority

Sprint

Development Team

Thor

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs
Created October 23, 2024 at 5:32 PM
Updated January 23, 2025 at 5:59 PM
Resolved October 23, 2024 at 5:49 PM
TestRail: Cases
TestRail: Runs