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

dev: updates internal code borrowed from Go #5098

Merged
merged 17 commits into from
Nov 2, 2024

Conversation

ldez
Copy link
Member

@ldez ldez commented Oct 31, 2024

This PR updates the internal code borrowed from Go.

The main element is the cache package.

The initial version from #699 (2019) is a mix between go1.12 and go1.13 (more details inside internal/cache/readme.md).

The main modifications are about error handling: the official Go cache implementation ignores many errors, and the implementation inside Golangci-lint reports those "hidden" errors.

I reverted minor changes and isolated custom modifications (but not all modifications can be isolated) to minimize divergences before synchronizing the code with each Go version.

I spent a lot of time analyzing the code to be able to make the right updates.

The packages mmap, quoted are just copies of the Go code without any changes.
The package testenv has been trimmed to just keep one function (avoid complex copy for imports) without other changes.
The package renameio has been removed from Go and "replaced" by lockedfile, I used the module github.com/rogpeppe/go-internal instead of copying the code.

There is one commit by topic and one commit by Go version.

Side effect:
The support of the experimental programmatic cache (GOLANGCI_LINT_CACHEPROG).

Note 1:
I think the code of the PR is not reviewable as a classic PR because it's synchronization with the Go code.
The code from Go must not be changed to ease future synchronization, and some custom codes are written in a style to ease the diff.

Note 2:
I did some benchmarks and I didn't notice any performance improvements or regression after the update.

Note 3:
If you are asking if it was painful to update, the answer is yes: it was long and painful 😄
But future synchronization will be "easier", at least easier than this one.


This PR is the first part of the refactoring of the golangci-lint core, but don't expect another PR quickly because, currently, the code is pure spaghetti 🍝.

This is a long-term goal. Regularly, I try this refactor. Each time, I learn more, but still not enough to be confident.


Closes #4986
Related to golang/go#59719

@ldez ldez added enhancement New feature or improvement area: cache labels Oct 31, 2024
@ldez ldez added this to the next milestone Oct 31, 2024
@ldez ldez mentioned this pull request Oct 31, 2024
3 tasks
@ldez ldez requested review from bombsimon and ryancurrah October 31, 2024 23:37
@ldez ldez changed the title dev: updates the code the internal code borrowed from Go dev: updates code of the internal code borrowed from Go Oct 31, 2024
@ldez ldez changed the title dev: updates code of the internal code borrowed from Go dev: updates internal code borrowed from Go Oct 31, 2024
@ldez ldez force-pushed the feat/cache-sync-go branch 3 times, most recently from ffd5e64 to 9be932c Compare November 1, 2024 00:28
@ldez ldez force-pushed the feat/cache-sync-go branch from 9be932c to 0f97a4c Compare November 1, 2024 18:10
Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@ldez ldez merged commit 071fd10 into golangci:master Nov 2, 2024
15 checks passed
@ldez ldez deleted the feat/cache-sync-go branch November 2, 2024 20:59
@ldez ldez modified the milestones: next, v1.62 Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cache enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Remote Cache for golangci-lint
2 participants