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

go.dev: change "copy" link to be full import statement #36809

Closed
myitcv opened this issue Jan 27, 2020 · 9 comments
Closed

go.dev: change "copy" link to be full import statement #36809

myitcv opened this issue Jan 27, 2020 · 9 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Jan 27, 2020

What is the URL of the page with the issue?

https://pkg.go.dev/testing?tab=doc

What is your user agent?

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.66 Safari/537.36

Screenshot

Screen Shot 2020-01-27 at 19 19 44

What did you do?

Visited the above page.

What did you expect to see?

Firstly, the presence of the "copy" link to the right of the package path is welcomed: thank you!

However, godoc has this nice feature whereby the first thing at the top of the page is a complete import statement:

Screen Shot 2020-01-27 at 19 20 14

I'd like to suggest that we change pkg.go.dev to behave in the same way, such that clicking on the "copy" link would result in the following contents on the clipboard:

import "testing"

What did you see instead?

Only testing is copied to the clipboard.

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite labels Jan 27, 2020
@julieqiu julieqiu changed the title go.dev: consider adding copy-pasteable import statement at top of page go.dev: change "copy" link to be full import statement Jan 28, 2020
@julieqiu
Copy link
Member

/cc @jba

@jba
Copy link
Contributor

jba commented Jan 29, 2020

We did that because most of the time, the file in which you'd like to paste the result already has an import block, with parens.

But perhaps we're missing other use cases of this feature?

@myitcv
Copy link
Member Author

myitcv commented Jan 29, 2020

We did that because most of the time, the file in which you'd like to paste the result already has an import block, with parens.

If this is the case, then I think making the copied value "testing" would have been a better choice, no?

However I'm not clear that "most of the time" there will be an existing import declaration group (if that's the name given to a go/ast.GenDecl which has a valid Lparen and Rparen) - is there something that points to this likely being the case?

Regardless, if the copied value is import "testing" then it can trivially be added as a new import declaration and then tools like gopls/goimports can tidy things up.

@jba
Copy link
Contributor

jba commented Jan 29, 2020

Let me ask you: why is import "testing" better than "testing" or testing?

@myitcv
Copy link
Member Author

myitcv commented Jan 29, 2020

Because I can paste it directly into any .go file without needing to make any further changes to the import (group).

@jba
Copy link
Contributor

jba commented Jan 31, 2020

Sounds reasonable. Will do.

@gopherbot gopherbot added this to the Unreleased milestone Feb 6, 2020
@jba
Copy link
Contributor

jba commented Feb 13, 2020

This has been fixed and will appear after the next deployment, sometime next week.

@jba jba closed this as completed Feb 13, 2020
@jba
Copy link
Contributor

jba commented Feb 20, 2020

Live now.

@myitcv
Copy link
Member Author

myitcv commented Feb 22, 2020

Thank you!

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jun 15, 2020
The copy button at the top of a details page now puts

   import "path"

on the clipboard, rather than just path. This makes
it easier to simply paste the result into Go code.

Fixes golang/go#36809.

Change-Id: I52360a3d1a02214b10a27d39f9d0b2ddad7e0d4e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/665367
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Jun 15, 2020
The copy button at the top of a details page now puts just the path
on the clipboard, rather than

   import "path"

Updates golang/go#36809.
Updates golang/go#38514.

Change-Id: I7f475d0415f67a4ff72e95abef750d2604717a51
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/722967
Reviewed-by: Julie Qiu <julieqiu@google.com>
@golang golang locked and limited conversation to collaborators Feb 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Projects
None yet
Development

No branches or pull requests

4 participants