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

Closed
fwhezfwhez opened this issue Feb 20, 2021 · 5 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@fwhezfwhez
Copy link

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
@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
@seankhliao seankhliao added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels 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

CC @stamblerre

@stamblerre
Copy link
Contributor

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.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Feb 24, 2021
@stamblerre stamblerre added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed FeatureRequest labels Feb 24, 2021
@fwhezfwhez
Copy link
Author

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 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 on-deck Feb 28, 2021
@stamblerre
Copy link
Contributor

Closing this issue as there hasn't been any activity on it for 2 weeks. Please file a new issue if unimported completions do not work for you.

@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Mar 11, 2021
@stamblerre stamblerre moved this from To Do to Done in gopls on-deck Aug 12, 2021
@golang golang locked and limited conversation to collaborators Mar 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
No open projects
Development

No branches or pull requests

5 participants