Open hoeppi-google opened 2 months ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
cc @mateusz834
That is true that:
type S struct {
//- comment
Name *string
}
was formatted to this:
type S struct {
// - comment
Name *string
}
but, formatting:
type S struct {
//- comment
Name *string
}
formats it to this:
type S struct {
//- comment
Name *string
}
There is no change.
Before CL 609077 the godoc formatting was performed for all comments, that start at the first Column of a line, this is wrong (e.g. for comments at the first column inside of a func declaration). I think that the fix is right.
Maybe there should be a separate discussion to always start adding a space before a comment?
Change https://go.dev/cl/612137 mentions this issue: go/printer: revert "do not treat comments inside a ast.Decl as godoc"
CC @griesemer
This change was reverted, without any further discussion here with a comment:
it turned out to also introduce a change to the formatting as described in issue #69382, which wasn't intended.
This formatting change was intended, see my comment above: https://github.com/golang/go/issues/69382#issuecomment-2341595364 and the test case, with a similar case (go doc formatting in not executed).
Would like to hear how we should now move forward with this change.
@mateusz834 Apologies for the revert w/o external discussion. W/o going details, this change broke some Google internal tests and in order to unblock this we decided to revert this change for now. The correct fix may well be that we need to make some changes to the internal code, but we haven't had the time to look into it. If we decide to do that, we may be able to simply reapply your CL. Thanks.
go.dev/cl/609077 causes a change in formatting. Reading the CL description and the test cases leads me to believe that this change is unintended.
Reproducer:
Before go.dev/cl/609077, this printed:
After go.dev/cl/609077, this prints: