Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

cmd/golint: introduce auto fix option (--fix) #476

Closed
wants to merge 4 commits into from

Conversation

moznion
Copy link

@moznion moznion commented Dec 10, 2019

This patch introduces an option to fix pointed out warnings automatically.
This one provides such function partially; actually it has the only naming auto-correction.

To be honest, I'm not confident about how to test this feature, this patch contains a simple shell-script based test as you can see. Could you please tell me if there is a good way?

Update: I wrote a test case to check the behavior of auto-fix mode at 86ac914

It can fix like so:
https://github.com/golang/lint/blob/9ceeaa38f1710f96dd9f0dc840a44b4e0de0c390/testdata/names.go
=>
https://github.com/golang/lint/blob/9ceeaa38f1710f96dd9f0dc840a44b4e0de0c390/testdata/auto_fix/expected.go

Ref #214

@gopherbot
Copy link

This PR (HEAD: c2b0edc) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

This patch introduces an option to fix pointed out warnings automatically.
This one provides such function partially; actually it has the only naming auto-correction.

Ref golang#214
@gopherbot
Copy link

This PR (HEAD: 00dcd60) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

If not, `format.Node()` outputs the source code that has
comments on an incorrect position.
@gopherbot
Copy link

This PR (HEAD: 86ac914) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

… name rule on fix mode

When `*ast.Ident` value was fixed, it doesn't show a warning message.
@gopherbot
Copy link

This PR (HEAD: 9ceeaa3) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

This PR (HEAD: 601803c) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/lint/+/210659 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@ydnar
Copy link

ydnar commented May 30, 2020

Any plans to land this PR?

@david-nyt
Copy link

Would love to see this merged in!

@gopherbot
Copy link

This PR is being closed because golang.org/cl/210659 has been abandoned.

Thank you for submitting this patch! As proposed[1], we are freezing and deprecating golint. There's no drop-in replacement to golint per se, but you should find that Staticcheck[2] works well in encouraging good Go code, much like golint did in the past, since it also includes style checks. There's always gofmt and "go vet" too, of course.

If you would like to contribute further, I'd encourage you to engage Staticcheck's issue tracker[3] or look at vet's open issues[4], as they are both actively maintained. If you have an idea that doesn't fit into either of those tools, you could look at other Go linters[5], or write your own - these days it's fairly straightforward with go/analysis[6].

To help avoid confusion, I'm closing all CLs before we freeze the repository. If you have any feedback, you can leave a comment on the proposal thread where it was decided to deprecate golint - though note that the proposal has been accepted for nearly a year. Thanks!

[1] golang/go#38968
[2] https://staticcheck.io/
[3] https://github.com/dominikh/go-tools/issues
[4] https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+cmd%2Fvet+in%3Atitle
[5] https://github.com/golangci/awesome-go-linters
[6] https://pkg.go.dev/golang.org/x/tools/go/analysis

@gopherbot gopherbot closed this May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants