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: Auto-make-up when calling public method or value after press '.' #44450

Open
fwhezfwhez opened this issue Feb 20, 2021 · 4 comments
Open

Comments

@fwhezfwhez
Copy link

@fwhezfwhez fwhezfwhez commented Feb 20, 2021

On the case you want to build a new project when there exists old projects, using GOPATH, Every outer-package public method can be well auto-make-up after press '.'

But now using gomodule, It can hardly auto-make-up method name unless I'm aware of what I want to import, then first go get it and then use it. This is too bad!

@gopherbot gopherbot added this to the Proposal milestone Feb 20, 2021
@gopherbot gopherbot added the Proposal label Feb 20, 2021
@fwhezfwhez fwhezfwhez changed the title Proposal: Auto make-up package calling after press '.' Proposal: Auto-make-up when calling public method or value after press '.' Feb 20, 2021
@seankhliao seankhliao changed the title Proposal: Auto-make-up when calling public method or value after press '.' proposal: x/tools/gopls: Auto-make-up when calling public method or value after press '.' Feb 20, 2021
@ianlancetaylor ianlancetaylor changed the title proposal: x/tools/gopls: Auto-make-up when calling public method or value after press '.' x/tools/gopls: Auto-make-up when calling public method or value after press '.' Feb 24, 2021
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Unreleased Feb 24, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 24, 2021

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Feb 24, 2021

gopls does offer autocompletion for unimported packages that are available in your module cache ($GOPATH/pkg/mod). I'm not aware of any features in GOPATH mode that would provide completions for packages you have not downloaded yet.

If you can share a specific example of this issue, please do so. Please also take a look at our troubleshooting guide and attach your gopls logs.

@fwhezfwhez
Copy link
Author

@fwhezfwhez fwhezfwhez commented Feb 25, 2021

@stamblerre
gopls now works well, and this issue is not reporting a bug.

When I take response to many projects, and now I want to start a new project.

In the past using GOPATH, starting a new project is just convenient because all packages can be well completed by gopls because all these normal packages're already in GOPATH as old project have downloaded them and share them.

Now using GOMODULE, even if I've hold many existed projects, when I start a new app project, I still need to consider which package I should go get first and then I can using gopls to auto completed its dot tip. I hope there exists a scheme that gopls can make-up a package that I use it in my new project in the first time(that it's just not go get yet), it can privilagedly refer to a package's newest version locally.

For example:
I own app1, app2 ,app3, app4 four projects and have built a big enough GOPATH/pkg/mod/....., they contains gin

GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.1.0
GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.2.0
GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.3.0
GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.4.0

then, I want to start a new app5. At the first moment,

  • the go.mod is empty.
  • Go111module is on.
  • I havent run go get github.com/gin-gonic/gin in app5 yet

Then I press gin.

At this time , gopls should refer to existed versions of gin where old existed projects just fullfill it. They're:

GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.1.0
GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.2.0
GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.3.0
GOPATH/pkg/mod/github.com/gin-gonic/gin@v1.4.0

Gopls counts a latest version of gin and then choose v1.4.0 to finish its dot tip completion.

Then I got tip:

gin.
      |.New()
      |.Default()
      |.....

Emmm, I've asked my mates this situation. They ask me back:

How auto-completion knows which version of gin to pick?

Should this supported by IDE not go chain?

I'm also comfused of this!

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Feb 25, 2021

This workflow already exists in gopls--it is what we refer to as unimported completions. Can you please try this out and share a log if it doesn't work as expected?

@stamblerre stamblerre added this to To Do in gopls: v1.0.0 Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants