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
go/format: does not format comments correctly the first time #62559
Comments
I think this is from the \r in the indented line https://go.dev/play/p/E_YXQBvv0Uq |
cc @griesemer |
@seankhliao Thanks for the simplified example - very helpful. It does appear the the As an aside, we are aware that gofmt is not idempotent. |
cc @mvdan (in case you're interested) |
Indeed I am interested :)
Meaning that it's always been a known problem and you're okay with that limitation, or that there are idempotency bugs that should be fixed sooner than later? I always worked under the assumption that gofumpt should be idempotent. In fact I have a number of idempotency issues open in gofumpt which worry me. Perhaps trying to fix those before we make gofmt properly idempotent wouldn't be a very good idea. As a side note, I feel like fuzzing would be a helpful tool to find idempotency issues. Given any input which parses as valid Go, formatting a second time with |
It would be great if the idempotency bugs were fixed - but I think it's non-trivial to do so. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to format some go code, at first formatting the comments are not correctly formatted. When i format again the correct result is produced.
I have no minimal example and i also could not create an easier example, hence the byte array. It is taken from a code generator i work on.
code
https://go.dev/play/p/KtdOV-TRZZZ
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: