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

cmd/gofmt: gofmt does not format indented comments #53005

Open
ayushr2 opened this issue May 19, 2022 · 3 comments
Open

cmd/gofmt: gofmt does not format indented comments #53005

ayushr2 opened this issue May 19, 2022 · 3 comments
Labels
NeedsInvestigation WaitingForInfo

Comments

@ayushr2
Copy link

@ayushr2 ayushr2 commented May 19, 2022

$ /tmp/go/bin/go version
go version devel go1.19-668041e Tue May 17 18:55:46 2022 +0000 linux/amd64

gofmt does not format indented comments anymore. Simple reproducer:

$ cat ~/test.go 
package test

//Top level bad comment.
func main() int {
        //Indented bad comment.
}
$ /tmp/go/bin/gofmt ~/test.go 
package test

// Top level bad comment.
func main() int {
	//Indented bad comment.
}
@prattmic prattmic added this to the Go1.19 milestone May 19, 2022
@prattmic prattmic added the NeedsInvestigation label May 19, 2022
@prattmic
Copy link
Member

@prattmic prattmic commented May 19, 2022

cc @rsc

@prattmic
Copy link
Member

@prattmic prattmic commented May 19, 2022

I believe this is working as intended.

From the proposal: "We propose that gofmt and go/printer reformat doc comments to a conventional presentation, updating old syntax to new syntax and standardizing details such as the indentation used for preformatted blocks, the exact spacing in lists, and so on."

Your "indented bad comment" is not a doc comment, and thus does not get formatted. That would be another proposal.

Was this a change in behavior? Then it may be a bug. I don't believe we used to do any formatting of comments, but I could be forgetting. Do you have an example of changed behavior?

@mvdan mvdan added the WaitingForInfo label May 20, 2022
@mvdan
Copy link
Member

@mvdan mvdan commented May 20, 2022

I agree with @prattmic - I also confirmed that Go 1.18.2's gofmt does not modify either of the two comments.

Removing from the 1.19 milestone, because the regression that the issue reports seems to not be present.

@mvdan mvdan removed this from the Go1.19 milestone May 20, 2022
@seankhliao seankhliao added WaitingForInfo and removed WaitingForInfo labels Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation WaitingForInfo
Projects
None yet
Development

No branches or pull requests

4 participants