-1

I love the role that gofmt has in Go programming. We would rather, though, that the following:

func somefunc(
    a *sometype, // Explanation of a
    b int, // Explanation of b
    longName float64, // Explanation of longName
) {
...

be able to be formatted like:

func somefunc(
    a        *sometype, // Explanation of a
    b        int,       // Explanation of b
    longName float64,   // Explanation of longName
) {
...

similar to how structs are formatted, and keeping with our coding standards for other languages. Is there any provision for accommodating local preferences like these, or is this "not the way we do things around here"? I couldn't find any access to the patterns that gofmt uses, so my guess is "no".

Community
  • 1
  • 1
Scott Deerwester
  • 3,503
  • 4
  • 33
  • 56
  • 1
    The goal of `gofmt` is to standardize code style across all Go code; making it customizable would be in direct opposition to its goal. – Adrian Mar 27 '19 at 15:24
  • 2
    «Gofmt's style is no one's favorite, yet gofmt is everyone's favorite.» From [there](https://go-proverbs.github.io/). – kostix Mar 27 '19 at 15:31
  • 1
    Yeah, `go` questions answered in the docs will generaly end up downvoted. Regarding your example, per godoc, the proper place for documentation is on the line preceding the declaration. – JimB Mar 27 '19 at 20:31

1 Answers1

6

Can Go accommodate local coding standard preferences?

No. You guessed correctly.

(The whole reason for a standard is to have one, instead of one per person/organization.)

Volker
  • 40,468
  • 7
  • 81
  • 87