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: consider auto-detecting the module to provide -local without a config #40660

Open
stamblerre opened this issue Aug 10, 2020 · 4 comments
Labels
FeatureRequest gopls/imports gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@stamblerre
Copy link
Contributor

See the conversation on #31999 and #32049.
Could we add some special value of the setting and have it automatically infer the name of the current module? For use cases where -local is not necessarily the path of current module, we could still allow a configuration as before.

/cc @heschik

@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Aug 10, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 10, 2020
@segevfiner
Copy link
Contributor

Just note that what goimports needs is a prefix. So if your package is something like github.com/segevfiner/magicgopher, then it needs to be set too github.com/segevfiner. It is also actually a comma-separated list for some more complex cases, so having a setting for it is still definitely useful. Though honestly, goimports should have detected a config file in the repository root or something (Which gopls would also support), so such a setting like that is shared across devs and different code editors without them having to set it up themselves or depend on some specific editor configuration sharing facility.

@heschi
Copy link
Contributor

heschi commented Aug 10, 2020

I personally wish -local had never been added. (@bradfitz may have his own opinion.) I don't particularly want to encourage its adoption. We're definitely not going to create a goimports config file without a much more compelling reason.

A setting that automatically sets -local from the module prefix is still a problem for anyone that works on some projects that use -local and some that don't. I would want there to be more demand before we considered adding it.

@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Aug 10, 2020
@stamblerre stamblerre added this to the gopls/unplanned milestone Oct 21, 2020
@michaelbeaumont
Copy link

Why exactly don't people want to encourage -local? It seems to be a very common pattern to have 3 groupings. Couldn't something like -local-mod be added, to be equivalent to goimports -local $(go list -m)

@luisdavim
Copy link

A setting that automatically sets -local from the module prefix is still a problem for anyone that works on some projects that use -local and some that don't. I would want there to be more demand before we considered adding it.

I don't see how this would be a problem, we can add a flag named -auto-local or something like that and if that's used it just finds the local prefix from the module name and prepends it to the list of locals set by -local users would be in control, but this would allow people that want to use this functionality to have generic makefiles or IDE configuration that works consistently across their projects without special config...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls/imports gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

7 participants