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: specify Options.LangVersion when invoking gofumpt #43998

Open
mvdan opened this issue Jan 29, 2021 · 1 comment
Open

x/tools/gopls: specify Options.LangVersion when invoking gofumpt #43998

mvdan opened this issue Jan 29, 2021 · 1 comment

Comments

@mvdan
Copy link
Member

@mvdan mvdan commented Jan 29, 2021

gofumpt's API has an option to specify the Go language version to target: https://pkg.go.dev/mvdan.cc/gofumpt/format#Options

Unfortunately, this seems to not be wired into gopls: https://github.com/golang/tools/blob/e9a2c0706a5b9cc8ee5965d5a50c996ffb255a7b/gopls/internal/hooks/hooks.go#L26

This results in gofumpt having to fall back to assuming the code has to comply with Go 1.0 as a language, not enabling rules which affect newer language features such as octal numbers.

This should be an easy fix, I think. When run from the command line, gofumpt uses the version specified in go.mod, so gopls could do the same.

cc @stamblerre @ianthehat

@twmb
Copy link
Contributor

@twmb twmb commented Jul 28, 2021

If possible, this would be a good opportunity for a general mechanism to wire passing flags through gopls to formatters (so, for example with gofumpt, -extra).

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

Successfully merging a pull request may close this issue.

None yet
4 participants