x/tools/gopls: support renaming a test package to make it external #69107
Labels
FeatureRequest
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What did you do?
Using gopls to develop Go tests. Working on a test package
foo
, I need to make it an external packagefoo_test
, as otherwise I start running into import cycles when adding some more imports.What did you expect to see?
Gopls should support renaming the package name in a test file from
foo
tofoo_test
via its rename action. It would effectively do the same that I now do manually, which is:foo
tofoo_test
foo
packagefoo
package, such asBar
andBar.Baz
, tofoo.Bar
andfoo.Bar.Baz
.Note that this process could fail if one of the unqualified references was unexported like
bar
, since that can't be reached via an import. I think it's fine for gopls to leave the brokenfoo.bar
in this case, and let the user deal with the problem with the best solution - which might be to export the name, or to use anexport_test.go
file, or use existing exported API instead. But gopls should still aim to do as much as possible here, even if the result still has a few build errors.What did you see instead?
Build info
The text was updated successfully, but these errors were encountered: