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

New Feature: Copy Go Package Path #3394

Closed
xhd2015 opened this issue May 18, 2024 · 2 comments
Closed

New Feature: Copy Go Package Path #3394

xhd2015 opened this issue May 18, 2024 · 2 comments

Comments

@xhd2015
Copy link

xhd2015 commented May 18, 2024

Is your feature request related to a problem? Please describe.
When working with go code, it is quite common to import packages by path, however I found there were no quick way to do this. I must go to the dir of the package I want to import, copy it's relative path, and concatenate that with the go module path to form a package path. It's just so painful how many times I needed to do this, and it's also too ineffective!

Describe the solution you'd like
Add a quick action in vscode-go plugin to copy the go package path with one click.

Describe alternatives you've considered
As described above, previously I manually concatenate strings together.

Additional context

I actually have made a vscode plugin that already does this, want to check here if it is generally needed by the community. If so, we may add it to vscode-go.

Step 1: copy
image

Step 2: paste
image

The repository is at https://github.com/xhd2015/VSCode-Ext-Copy-Go-Package-Path .

I'll later propose a PR for reviewing purpose.

Thanks.

@gopherbot gopherbot added this to the Untriaged milestone May 18, 2024
@hyangah
Copy link
Contributor

hyangah commented May 20, 2024

Good to develop and share the extension. I think it's good to have it a separate extension.

Ideally, users shouldn't worry about imports - users just start to use the package, and the language server should be able to auto-import the package (especially those already in the workspace). For example, in the following example, I didn't import counter package yet, but the language server recognizes the package and includes suggestions based on the API of the package. As I accept one of them, the language server provides the extra edit for the import block. This is the workflow we want to support.

Screenshot 2024-05-20 at 10 05 35 AM

We understand that currently some bugs in package imports sometimes prevent this ideal workflow. The gopls team is actively working on fixing and improving the import logic.

@xhd2015
Copy link
Author

xhd2015 commented May 20, 2024

Agreed, I'll publish the extension alone. Thansk.

@xhd2015 xhd2015 closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants