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

proposal: go.ast: add CommentGroup.Raw function #67047

Open
oldme-git opened this issue Apr 26, 2024 · 3 comments · May be fixed by #66868
Open

proposal: go.ast: add CommentGroup.Raw function #67047

oldme-git opened this issue Apr 26, 2024 · 3 comments · May be fixed by #66868
Labels
Milestone

Comments

@oldme-git
Copy link

Proposal Details

Sometimes, We need to get the raw (original) comments to generate some go template files. But CommentGroup.Text does not get the raw (original) comments. This makes it difficult to add comments to the generated template file.
Thank you for your contribution to go! Have a good day!

PR here: https://go-review.googlesource.com/c/go/+/579475

@gopherbot gopherbot added this to the Proposal milestone Apr 26, 2024
@oldme-git oldme-git linked a pull request Apr 26, 2024 that will close this issue
@ianlancetaylor
Copy link
Contributor

CC @griesemer @alandonovan

@gopherbot
Copy link

Change https://go.dev/cl/579475 mentions this issue: go.ast: add CommentGroup.Raw function

@adonovan
Copy link
Member

adonovan commented Apr 26, 2024

The proposed Raw function does not return the original text: windows CR LF line endings have been replaced by "\n" , for example, and a /*...*/ comment at EOF would appear to have a spurious following newline.

Also, the Raw function is easy to write outside the go/ast package, and doesn't require any special intuition or knowledge.

I don't think we should add it to CommentGroup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

Successfully merging a pull request may close this issue.

4 participants