I use golint in addition to staticcheck, but over time staticcheck has incorporated a lot of the useful checks from golint. Additionally, golint is poorly maintained and isn't as nice to use. I'd love to completely stop using golint, but there are some checks I would miss.
I went through each of the checks golint has and verified whether they are in staticcheck. First, here are the ones which staticcheck already has:
Here are the checks golint has which are not provided by staticcheck, along with my own notes about whether I think they're useful.
To summarize, I propose adding the following checks to staticcheck:
ST1???:
- Blank imports in non-main packages should have justifying comments.
- All exported names should have doc comments.
- Doc comments on exported names should be of the normal form ("Foo ...", etc.)
- Exported names should not stutter with the package name.
- Statements that increment/decrement a variable should use x++/x--.
- Exported functions should not return unexported types.
- Functions which take context.Contexts should accept them as the first argument.
SA4???:
- The LHS of a decl shouldn't have a redundant type that can be inferred from the RHS.
SA1???:
- Calls to context.WithValue should not use a basic type for the key.
Perhaps if we can agree on a set of checks you think are worth adding, I can open issues for each of those and close this issue.
I use golint in addition to staticcheck, but over time staticcheck has incorporated a lot of the useful checks from golint. Additionally, golint is poorly maintained and isn't as nice to use. I'd love to completely stop using golint, but there are some checks I would miss.
I went through each of the checks golint has and verified whether they are in staticcheck. First, here are the ones which staticcheck already has:
Package comments (ST1000)
Imports
Ranges
for range ...instead offor _, _ = range ...(S1005)for i := range ...instead offor i, _ = range ...(S1005)Errorf
fmt.Errorf(...)instead oferrors.New(fmt.Sprintf(...)). (S1028)Errors
Error strings (ST1005)
Names (ST1003)
Receiver names
Error return
Here are the checks golint has which are not provided by staticcheck, along with my own notes about whether I think they're useful.
Blank imports:
Exported names:
Names:
languages? I've never come across this.]
VarDecls:
Elses:
elseif theifends in a return. [I think staticcheck got rid of this check? I don't really agree with it as a blanket rule.]Inc/Dec:
Unexported return:
Time names:
Context: [These both seem worth having.]
argument. (See https://golang.org/issue/17293.)
argument.
To summarize, I propose adding the following checks to staticcheck:
ST1???:
SA4???:
SA1???:
Perhaps if we can agree on a set of checks you think are worth adding, I can open issues for each of those and close this issue.