Skip to content
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

gofmt: not ideal formatting of overlong parameter lines containing newlines #1524

Closed
griesemer opened this issue Feb 17, 2011 · 5 comments
Closed

Comments

@griesemer
Copy link
Contributor

package p
func ManageStatus(in <-chan *Status, req <-chan Request,
    stat chan<- *TargetInfo, TargetHistorySize int) {
}

is formatted:

package p

func ManageStatus(in <-chan *Status, req <-chan Request,
stat chan<- *TargetInfo, TargetHistorySize int) {
}

The 2nd parameter line should probably be indented.
@bradfitz
Copy link
Contributor

Comment 1:

Just about filed a dup and found this bug.
I'm always reminded of this quirk when I edit this file:
http://camlistore.org/code/?p=camlistore.git;a=blob;f=lib/go/camli/blobserver/interface.go;hb=HEAD
(the Stat and EnumerateBlobs methods)

@moraes
Copy link
Contributor

moraes commented Sep 1, 2011

Comment 2:

I avoid gofmt because of this. :P
Ideally it should align with parentheses:
func ManageStatus(in <-chan *Status, req <-chan Request,
                  stat chan<- *TargetInfo, 
                  TargetHistorySize int) {
}
...or start args indented in the next line and keep aligned that way on next lines:
func ManageStatus(
    in <-chan *Status, req <-chan Request,
    stat chan<- *TargetInfo, TargetHistorySize int) {
}
But that just my opinion! :)

@gopherbot
Copy link

Comment 3 by andychilton:

In a similar vein to what Rodrigo suggested, I'd go one step further. If the line has to
be broken due to the length, make sure _all_ parameters are on a separate line. I find
this easier to read (and of course this is just a suggestion and my opinion):
func ManageStatus(
    in <-chan *Status,
    req <-chan Request,
    stat chan<- *TargetInfo, 
    TargetHistorySize int
) {
    ...etc...
}

@moraes
Copy link
Contributor

moraes commented Sep 1, 2011

Comment 4:

@andy: your example would need to be:
func ManageStatus(
    in <-chan *Status,
    req <-chan Request,
    stat chan<- *TargetInfo, 
    TargetHistorySize int) {
    ...etc...
}
Because your version won't compile, afaik.

@griesemer
Copy link
Contributor Author

Comment 5:

This issue was closed by revision c106790.

Status changed to Fixed.

@griesemer griesemer self-assigned this Sep 6, 2011
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants