Skip to content

go/printer: false positive for doc comment formatting on unindented input #52605

Closed

Description

@rsc

The added blank line in the comment shows that go/printer is treating this as a doc comment, even though it's not.
It is being tricked by the lack of indentation, which I used as part of the signal for "top-level comment".
Very minor, but should do better.

% cat /tmp/x.go
package p

type T struct {
// This is not
//	a doc comment.
X int
}
% gofmt /tmp/x.go
package p

type T struct {
	// This is not
	//
	//	a doc comment.
	X int
}
%

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Apr 28, 2022
  2. added this to the Go1.19 milestone on Apr 28, 2022
  3. self-assigned this
    on Apr 28, 2022
  4. modified the milestones: Go1.19, Go1.20 on Aug 2, 2022
  5. modified the milestones: Go1.20, Go1.21 on Feb 1, 2023
  6. modified the milestones: Go1.21, Go1.22 on Aug 8, 2023
  7. modified the milestones: Go1.22, Go1.23 on Feb 6, 2024
  8. gopherbot commented on Apr 20, 2024

    @gopherbot
    Contributor

    Change https://go.dev/cl/579978 mentions this issue: go/printer: fix false positive doc comment

  9. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Apr 24, 2024
  10. modified the milestones: Go1.23, Go1.24 on Aug 13, 2024
  11. modified the milestones: Go1.24, Go1.25 on Feb 11, 2025
  12. modified the milestones: Go1.25, Go1.26 on Aug 12, 2025
  13. modified the milestones: Go1.26, Go1.27 on Feb 10, 2026
  14. added a commit that references this issue on May 18, 2026
    c1f0b9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions