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

goimports: provide own goimports #158

Closed
dominikh opened this issue Aug 14, 2017 · 3 comments
Closed

goimports: provide own goimports #158

dominikh opened this issue Aug 14, 2017 · 3 comments
Assignees
Labels

Comments

@dominikh
Copy link
Owner

Given our efforts on caching/indexing type information, we can provide a much faster, and slightly more accurate, goimports. This would primarily be of interest as part of the Language Server efforts (as the LS is guaranteed to have an up to date index at all times), but could be useful standalone, too.

The standalone version would have to ensure that the index is up to date. Specifics TBD.

There are two separate ways we can provide our own goimports

  1. Simply provide a virtual go/build.Context for the original goimports to use. This context would use our cache.

  2. Write our own goimports from scratch that queries the index directly. This would likely be faster than the first approach. It would also be necessary for implementing more accurate (i.e. more type aware) package selection.

@dominikh dominikh self-assigned this Aug 14, 2017
@dmitshur
Copy link
Sponsor Contributor

dmitshur commented Aug 14, 2017

The original goimports works on a single input .go file at a time, so it has some limitations as a result of that. For example, it can't tell if gl.ClearColor refers to the some gl package, or an unexported variable named gl in another .go file.

When you say, "slightly more accurate", do you mean this goimports would have the entire Go package as input and thus be able to resolve this limitation?

@dominikh
Copy link
Owner Author

dominikh commented Aug 14, 2017

It would have access to the whole package, yes. I was also thinking of the situation where you have two packages called foo with the same function Bar, but with different signatures or return types. If one choice results in valid code, and the other choice wouldn't compile, we can make the right choice.

@dominikh dominikh assigned dominikh and unassigned dominikh Sep 15, 2017
@dominikh
Copy link
Owner Author

This is no longer relevant. We've given up on our index ideas and chosen a much simpler caching based approach, which goimports won't benefit from. We're not working on a language server anymore, either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants