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/doc: go doc rsc.io/quote/v3 in module mode shows wrong import path #30778

Closed
rsc opened this issue Mar 12, 2019 · 13 comments

Comments

Projects
None yet
8 participants
@rsc
Copy link
Contributor

commented Mar 12, 2019

In module mode, in a module with rsc.io/quote/v3 as a dependency:

$ go doc rsc.io/quote/v3
package quote // import "rsc.io/quote"

Package quote collects pithy sayings.

func Concurrency() string
func GlassV3() string
func GoV3() string
func HelloV3() string
func OptV3() string
$ 

Note the import comment on the first line of output.
It should say rsc.io/quote/v3.
I do not know why it says rsc.io/quote instead.

@rsc rsc added this to the Go1.13 milestone Mar 12, 2019

@rsc rsc added the release-blocker label Mar 12, 2019

@go101

This comment has been minimized.

Copy link

commented Mar 12, 2019

It looks the specified import path doesn't work when modules feature is enabled.

@agnivade

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

/cc @robpike

@dmitshur

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

I'll be able to look into this issue.

@dmitshur

This comment has been minimized.

Copy link
Member

commented Mar 20, 2019

Actually, I can't reproduce this with Go 1.12.1 nor Go tip (at commit fd270d8):

$ cd $(mktemp -d)
$ go mod init m
go: creating new go.mod: module m
$ go get rsc.io/quote/v3
$ go doc rsc.io/quote/v3
package quote // import "rsc.io/quote/v3"

Package quote collects pithy sayings.

func Concurrency() string
func GlassV3() string
func GoV3() string
func HelloV3() string
func OptV3() string

@rsc What version of Go did you use? Where were the commands you ran before to initialize the main module?

@dmitshur

This comment has been minimized.

Copy link
Member

commented Apr 16, 2019

There's a chance this is the same issue as #28992 (comment).

@gopherbot

This comment has been minimized.

Copy link

commented Apr 20, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Apr 20, 2019

@dmitshur dmitshur reopened this Apr 20, 2019

@gopherbot gopherbot closed this Apr 20, 2019

@robpike robpike reopened this Apr 20, 2019

@andybons

This comment has been minimized.

Copy link
Member

commented May 16, 2019

@rsc is this still an issue? Do you have updated repro steps? Thanks.

@mseshachalam

This comment has been minimized.

Copy link

commented Jul 11, 2019

@dmitshur

$ go doc rsc.io/quote/v3
package quote // import "rsc.io/quote"

Package quote collects pithy sayings.

func HelloV3() string

I ran this on go version go1.12.6 linux/amd64 in a local module aftering go get rsc.io/quote/v3

@dmitshur

This comment has been minimized.

Copy link
Member

commented Jul 13, 2019

@mseshachalam Did you have a copy of rsc.io/quote repository in your GOPATH/src?

Can you check if commit 3b040b7 fixes it?

@mseshachalam

This comment has been minimized.

Copy link

commented Jul 15, 2019

@dmitshur I have a copy of `rsc.io/quote' at $GOPATH/src/rsc.io/quote pointing master branch at rsc/quote@5d9f230
I had to correct a syntax error at v3/quote.go

git diff v3/quote.go
diff --git a/v3/quote.go b/v3/quote.go
index 1f5f3d6..9b6071f 100644
--- a/v3/quote.go
+++ b/v3/quote.go
@@ -10,3 +10,4 @@ import "rsc.io/sampler"
 // Hello returns a greeting.
 func HelloV3() string {
        return sampler.Hello()
+}

I tested this with go 1.12.7 and observed the same behavior. Does this version of go include 3b040b7?

@dmitshur

This comment has been minimized.

Copy link
Member

commented Jul 15, 2019

Go 1.12.7 does not include it, it's currently only available on the latest master branch. You can use golang.org/dl/gotip to try it.

@mseshachalam

This comment has been minimized.

Copy link

commented Jul 16, 2019

Yeah. gotip works as expected.

seshachalamm@IMCHLT047:~/hello$ gotip doc rsc.io/quote/v3
package quote // import "rsc.io/quote/v3"

Package quote collects pithy sayings.

func Concurrency() string
func GlassV3() string
func GoV3() string
func HelloV3() string
func OptV3() string
seshachalamm@IMCHLT047:~/hello$ go doc rsc.io/quote/v3
package quote // import "rsc.io/quote"

Package quote collects pithy sayings.

func HelloV3() string

Could you please explain briefly about the changes in gotip and go 1.12.7 ?
The output is significantly different. I imagine gotip is using the tags of a library and go1.12.6 is using master branch ?

@dmitshur

This comment has been minimized.

Copy link
Member

commented Jul 16, 2019

Thanks for confirming @mseshachalam.

The change was CL 183991, you can read its commit message for details. It fixed issue #28992, which was that in some conditions, go doc was incorrectly using packages in your GOPATH workspace instead of from the appropriate module.

I imagine gotip is using the tags of a library and go1.12.6 is using master branch ?

Yes, it's now using the rsc.io/quote/v3 module (at some version as determined by your main module), instead of the v3 subdirectory of rsc.io/quote repository in your GOPATH workspace (on master branch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.