mvdan / gofumpt

A stricter gofmt
https://pkg.go.dev/mvdan.cc/gofumpt
BSD 3-Clause "New" or "Revised" License
3.15k stars 110 forks source link

Enforce some consistency with newlines at the start and end of parameter lists #262

Closed mmorel-35 closed 1 year ago

mmorel-35 commented 1 year ago

I don’t see any linter proposing to remove trailing comma and new line between } and ), so, I’m wondering if gofumpt would implement this rule.

So for example if I see

  myFunc(
    param1,
    myType{},
  )

I would expect to see this

  myFunc(
    param1,
    myType{})

It seems like gofumpt accept either ways. The linter is passing before and after my commit, here.

Would it be possible for gofumpt to provide this rule ?

mvdan commented 1 year ago

We have the rule "Composite literals should use newlines consistently", which is similar but more aggressive. I think this makes sense. The only thing to note is that we shouldn't modify the following:

myFunc(param1,
    myType{})

That is, we would enforce newlines at both the start and end of the parameter list if either end has a newline already.

mvdan commented 1 year ago

We could consider doing the same for function declarations too.

mvdan commented 1 year ago

Actually a duplicate of https://github.com/mvdan/gofumpt/issues/74; I had already agreed to doing this :)