ci: bump golangci-lint to v2.10, fix some prealloc linter warnings#5118
Conversation
rata
left a comment
There was a problem hiding this comment.
You mention you skip this in runc features, but it doesn't seem to be here. Wasn't it needed in the end and the commit is outdated?
There was a problem hiding this comment.
The more I look at this, the more unsure I am this is worth it. Linters should help us not review "trivial things" (like spaces, capitalization of variables, etc.) and make the code better.
If it ends up adding lot of "ignore this" everywhere, it is just too painful and we can remove it later. But I'm not convinced the value it adds. Also, our slices are not that big, I don't think it either has a big performance implication nor that the compiler in the future couldn't be smarter (our allocations are quite simple, most part of the same function).
Do you find yourself requesting this change on PRs? If so, then it is worth to have a linter.
If you like it, let's do add it :)
rata
left a comment
There was a problem hiding this comment.
LGTM, thanks!
The CI failures are new to me:
# chcon: failed to change context of '/tmp/bats-run-3MMyYP/runc.szTqBc/bundle/runc' to ‘system_u:object_r:container_runtime_exec_t:s0’: Invalid argument
They don't seem related at all, though :)
Looks like this is caused by a broken install of containers-selinux rpm: Restarted the job to see if it's something temporary. |
It is not. Addressed by #5123. |
Fix *some* of the prealloc linter warnings. While it does not make sense to address all warnings (or add prealloc to the list of linters we run in CI), some do make sense. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
|
Rebased to fix CI |
|
@lifubang @thaJeztah PTAL |
|
@kolyshkin this golang blog article about optimizing allocations was just published. The compiler is now much more effective: https://go.dev/blog/allocation-optimizations It's not that it doesn't make sense to do the length anymore, but it's way way better. |
ci: bump golangci-lint to v2.10
Preallocate some slices
These were found by the prealloc linter. While it does not make sense
to address all of prealloc warnings (or add it to the list of linters
we run in CI), some do make sense.