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

reflect: PkgPath returns un-importable path #12019

Closed
rgarcia opened this issue Aug 4, 2015 · 2 comments
Closed

reflect: PkgPath returns un-importable path #12019

rgarcia opened this issue Aug 4, 2015 · 2 comments
Milestone

Comments

@rgarcia
Copy link

rgarcia commented Aug 4, 2015

What version of Go are you using (go version)?

go version go1.5beta3 linux/amd64

What operating system and processor architecture are you using?

Ubuntu Precise 64 bit

What did you do?

I ran PkgPath on a reflect.Type in a vendored package: https://gist.github.com/rgarcia/f0c6507fbd1327d59bcf

(larger context: trying to solve golang/mock#4)

What did you expect to see?

A path string that does not include the "vendor" component.

What did you see instead?

A path string that includes "vendor" (and thus cannot be used as an actual import due to "must be imported as..." compiler error).

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Aug 4, 2015
@ianlancetaylor
Copy link
Member

I think that the current behaviour is probably correct, but leaving open because I'm not entirely certain.

@rsc
Copy link
Contributor

rsc commented Oct 16, 2015

The current behavior is correct. reflect must return a globally unique identifier. It's not guaranteed that you can write a program using PkgPath directly. For vendoring, you can't. You have to remove the .../vendor/ part and you have to make sure the source you put the import in is in the right subtree.

@rsc rsc closed this as completed Oct 16, 2015
@golang golang locked and limited conversation to collaborators Oct 17, 2016
@rsc rsc removed their assignment 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