-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
gofumpt --fix doesn't always work completely, gives conflicting results with standalone tool #1818
Comments
gofumpt seems to do the opposite of gofmt: $ gofumpt -w cni/cmd/istio-cni/main.go
$ git diff
diff --git i/cni/cmd/istio-cni/main.go w/cni/cmd/istio-cni/main.go
index abc3f91f3e..89e2468d2e 100644
--- i/cni/cmd/istio-cni/main.go
+++ w/cni/cmd/istio-cni/main.go
@@ -59,7 +59,7 @@ type Kubernetes struct {
// is passed in on stdin. Your plugin may wish to expose its functionality via
// runtime args, see CONVENTIONS.md in the CNI spec.
type PluginConf struct {
- types.NetConf // You may wish to not nest this type
+ types.NetConf // You may wish to not nest this type
RuntimeConfig *struct { // SampleConfig map[string]interface{} `json:"sample"`
} `json:"runtimeConfig"`
$ gofmt -w cni/cmd/istio-cni/main.go
$ git diff
$ @mvdan could you explain the reason? |
@ldez I don't know - I can't diagnose unless you provide the exact versions of gofmt and gofumpt, and a way to reproduce the difference between the two. A recent gofumpt version will only be format-compatible with a recent version of gofmt. Mixing gofumpt v0.1.0 with gofmt from Go 1.8 will likely result in diffs, for example. |
@mvdan I use gofmt from the go1.16 tag and the latest stable version of gofumpt:
same behavior with gofmt from go1.15, go1.14, go1.13, go1.12, go1.11 |
Thanks - that seems like a recent regression, added in mvdan/gofumpt@c49fa44. I mistook that formatting difference as a change in gofmt that happened a couple of years back. I've fixed the bug here: mvdan/gofumpt@d7cd0a5 |
I've now released that as part of a bugfix release: https://github.com/mvdan/gofumpt/releases/tag/v0.1.1 |
Thank you ❤️ |
Description of the problem
Running gofumpt standalone fixes more problems than gofumpt in golangci-lint.
Running
find | xargs -r -I{} sh -c 'echo {}; gofumpt -w {}'
vsgolangci-lint run --fix -c ./common/config/.golangci-format.yml -v
Version of golangci-lint
Config file
Go environment
Verbose output of running
Here you can see golangci-lint reverting a change gofumpt made:
$ gofumpt --version
v0.1.0
Code example or link to a public repository
You can run it on https://github.com/istio/istio. There are many files impacted, not just ni/cmd/istio-cni/main.go
The text was updated successfully, but these errors were encountered: