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

x/tools/gopls: reuse named imports from other packages in the current module #44510

Open
mvdan opened this issue Feb 22, 2021 · 0 comments
Open

x/tools/gopls: reuse named imports from other packages in the current module #44510

mvdan opened this issue Feb 22, 2021 · 0 comments

Comments

@mvdan
Copy link
Member

@mvdan mvdan commented Feb 22, 2021

Take the following dummy module with two simple Go files:

-- go.mod --
module test

go 1.14
-- foo/foo.go --
package main

import strs "strings"

var _ = strs.Count
-- bar/bar.go --
package main

var _ = strs.Builder

If I open both Go files with vim+govim+gopls and save, I would expect bar.go to gain import strs "strings", mimicking the other package in the same module. This works fine if both files are in the same package, but not if they are in different packages.

Assuming that gopls already collects information about all packages in the current main module, I think it should also be able to pick up named imports from other packages to try to be more helpful when adding imports.

In particular, this came up while writing tests in a new package with import qt "github.com/frankban/quicktest".

cc @heschik @stamblerre @myitcv @danp

@gopherbot gopherbot added this to the Unreleased milestone Feb 22, 2021
@stamblerre stamblerre removed this from the Unreleased milestone Mar 10, 2021
@stamblerre stamblerre added this to the gopls/unplanned milestone Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants