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

cmd/go: pass line number of generate directive in environment #9960

Closed
prencher opened this issue Feb 22, 2015 · 2 comments
Closed

cmd/go: pass line number of generate directive in environment #9960

prencher opened this issue Feb 22, 2015 · 2 comments
Milestone

Comments

@prencher
Copy link

It would be very useful if the go:generate command gained the ability to pass along file and line to the invoked tool, to avoid redundant definitions.

For example:

//go:generate -l stringer
type Pill int

const (
    Placebo Pill = iota
    Aspirin
)

Could pass along something like "Pill.go:42" to stringer.

Alternately, or in addition to, one could imagine //go:generate supporting a mode where it must be defined right before a type, variable or function, such that it could pass along that information to the tool.

@adg adg changed the title Ability for //go:generate commands to pass context to invoked tool cmd/go: //go:generate directives to pass context to invoked tool Feb 22, 2015
@rsc
Copy link
Contributor

rsc commented Apr 10, 2015

The file name is already there, in $GOFILE.
Perhaps $GOLINE should say 'foo.go:23'.
Plain GOLINE=23 seems too opaque.

@robpike

@rsc rsc changed the title cmd/go: //go:generate directives to pass context to invoked tool cmd/go: pass line number of generate directive in environment Apr 10, 2015
@rsc rsc added this to the Go1.5Maybe milestone Apr 10, 2015
@prencher
Copy link
Author

@rsc Ah, I had missed the $GOFILE environment variable. That's obviously cleaner than having command line arguments to go generate. Adding a $GOLINE to pair with it would be perfect.

@robpike robpike self-assigned this Apr 11, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe May 15, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned robpike 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

5 participants