Skip to content

Move custom linter settings to .golangci.yml file

In a prior change (!5398 (merged)), we added the support for custom linters on top of golangci-lint. In the first iteration, all settings for them are put in the implemenation file. This commit moves those settings to the manifeset file, along side with other linter settings.

golangci-lint doesn't support an official way to load the settings in de-facto manifest file .golangci.yml. Fortunately, we can hook into configuration parsing library viper that golangci-lint uses. Our custom linters are loaded at the end, just before executing the commands. At this time, golangci-lint established some state that stores the configuration. This state is process global, and accessible in our source code. In the future, if this approach doesn't work anymore, we can consider parsing the configuration file ourselves.

This MR also touches Makefile to add linting and testing targets for ./tools/golangci-lint/gitaly folder. Essentially, that folder has its own go.mod file. It cannot run tests a long side with other Go tests in Gitaly project.

Merge request reports