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

x/tools/cmd/stringer: add -autotrimprefix flag #22649

Closed
mvdan opened this issue Nov 9, 2017 · 4 comments
Closed

x/tools/cmd/stringer: add -autotrimprefix flag #22649

mvdan opened this issue Nov 9, 2017 · 4 comments

Comments

@mvdan
Copy link
Member

mvdan commented Nov 9, 2017

As an extension to -trimprefix=str, this flag would automatically detect the longest common prefix in all the generated constant names and trim it.

A possible alternative would be using a special value in -trimprefix instead, such as a character that cannot be part of a Go identifier. -trimprefix=-, -trimprefix=. and -trimprefix=^ have been suggested.

Branching off #16539, since that issue was primarily about the now implemented -trimprefix.

@gopherbot gopherbot added this to the Unreleased milestone Nov 9, 2017
@mvdan mvdan self-assigned this Dec 20, 2017
@gopherbot
Copy link

Change https://golang.org/cl/86155 mentions this issue: cmd/stringer: add -autotrimprefix flag

@mvdan
Copy link
Member Author

mvdan commented Jan 4, 2018

@adrianduke @jimmyfrasche @minux see the CL above - pinging all of you since you were discussing automatic detection of prefixes in the older issue.

@robpike
Copy link
Contributor

robpike commented Jan 4, 2018

I don't think this is necessary. String is run by go generate so one only types the prefix once. Also, since we're generating program text, it's good to be precise rather than implicit.

@robpike robpike closed this as completed Jan 4, 2018
@mvdan
Copy link
Member Author

mvdan commented Jan 5, 2018

Fair enough, your reasoning makes sense. I have to admit I went along with the suggestion in the original proposal without giving it much thought myself. Thankfully, I did not spend much time on the CL.

@golang golang locked and limited conversation to collaborators Jan 5, 2019
@rsc rsc unassigned mvdan Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants