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

additional checks in golang linter #34083

Open
TheFox0x7 opened this issue Mar 31, 2025 · 2 comments
Open

additional checks in golang linter #34083

TheFox0x7 opened this issue Mar 31, 2025 · 2 comments
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@TheFox0x7
Copy link
Contributor

Feature Description

more of a RFC than a gitea feature.


Are there any more linters which might be of interest?
https://golangci-lint.run/usage/linters/

Some are obviously no go for now (for example containedctx which I use to remove context from structs) but maybe there are some which we can toggle with benefits?

I think protogetter, intrange(?), usestdlibvars, prefsprint and mirror might be of some interest initially.

also linter we use now supports formatting which we could use? I didn't dig into it so far but there might be something interesting there.

Screenshots

No response

@TheFox0x7 TheFox0x7 added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Mar 31, 2025
@wxiaoguang
Copy link
Contributor

  • protogetter: no idea (unfamiliar)
  • intrange: well, not sure whether it really brings benefit, just like use switch instead of if, personally I do not like it because I'd like to write for i:=0;i<n;i++ or if-else freely ....
  • usestdlibvars: does it work with non-http package? Our case is: ctx.HTML(theCode, ...)
  • prefsprint & mirror: seems good

@TheFox0x7
Copy link
Contributor Author

  • protogetter helps prevent panics while reading protobuf result from what I see (getters instead field access)
  • I agree that intrange isn't terribly useful, though running modernize will change it anyway. I mentioned it because its basically free.
  • usestdlibvars - just checked and no. But there were only 3 cases of numeric code so i fixed it manually.

From others I've looked at in the meantime - prealloc and errorlint sound helpful too, though the second one is a lot of manual work

wxiaoguang added a commit that referenced this issue Apr 1, 2025
enable mirror, usestdlibbars and perfsprint 
part of: #34083

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

2 participants