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: suggest add $GOPACKAGEPATH for generate #10172

Closed
chai2010 opened this issue Mar 15, 2015 · 4 comments
Closed

cmd/go: suggest add $GOPACKAGEPATH for generate #10172

chai2010 opened this issue Mar 15, 2015 · 4 comments

Comments

@chai2010
Copy link
Contributor

Go generate sets several variables: $GOARCH/$GOOS/$GOFILE/$GOPACKAGE .

When we fork a gopkg, we need fix the old import path to current import path.
Like this:

//go:generate go run cmd/fixpath/fixpath.go -old=github.com/yuin/gopher-lua -new=github.com/chai2010/lua

Suggest add $GOPACKAGEPATH for import path.

https://github.com/chai2010/lua/blob/master/generate.go#L7

@adg
Copy link
Contributor

adg commented Mar 16, 2015

What would $GOPACKAGEPATH be set to in your example?

Using a go generate rule to rewrite import paths seems pretty strange. Can you provide more context?

@chai2010
Copy link
Contributor Author

When i fork a gopkg, like github.com/yuin/gopher-lua,
the origin gopkg's base import path is github.com/yuin/gopher-lua.

Some sub package (like gopher-lua/ast) still use github.com/yuin/gopher-lua/ast import path.
I can't build the new fork on new import path(on github.com/chai2010/lua).

I need to use go run fixpath.go -old-path=github.com/yuin/gopher-lua -new-path=github.com/chai2010/lua
to fix the import path.

When use the go generate to invoke the fixpath tool (to current import path),
i hope use $GOPACKAGEPATH instead of the github.com/chai2010/lua.

//go:generate go run cmd/fixpath/fixpath.go -old=... -new=$GOPACKAGEPATH

@rsc
Copy link
Contributor

rsc commented Apr 10, 2015

@robpike

I'm not convinced this is a proper use of go generate, nor that we want to keep throwing in environment variables.

@rsc rsc added this to the Go1.5Maybe milestone Apr 10, 2015
@bradfitz bradfitz changed the title cmd/go: suggest add $GOPACKAGEPATH for genreate cmd/go: suggest add $GOPACKAGEPATH for generate Apr 10, 2015
@robpike
Copy link
Contributor

robpike commented Apr 11, 2015

I agree with Russ. Closing.

@robpike robpike closed this as completed Apr 11, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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