Skip to content

Conversation

@eread
Copy link
Contributor

@eread eread commented Mar 26, 2025

With the release of golangci-lint version 2, some changes are needed to this package.

@eread eread force-pushed the eread/add-support-for-golangci_lint-version-2 branch 2 times, most recently from 244ba55 to 2e0ac76 Compare March 28, 2025 03:52
class GolangCILint(Linter):
cmd = 'golangci-lint run ${args} --out-format tab ${file_path}'
def cmd(self):
if self.settings.get("v1", False):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaste This is still too magical. Do we need to run golangci-lint version somehow and regex the version out of what's returned?

Copy link
Member

Choose a reason for hiding this comment

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

Right now, that would be just a manual setting. We would need to add that to the README and then the release notes.

Of course it would be possible to automate this, let me sketch that out. Let's see if I get that just out of my head:

import shutil
from SublimeLinter.lint import util
# first resolve the executable
if binary:= shutil.which("golangci"):
    stdout: str = util.check_output([binary, "<whatever arg it takes to return the version>"])
    # parse stdout with a regex or simpler if stdout.startswith("1.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaste Thanks! It occurred to me only later that we were creating a new setting. I actually like the idea of making it just a setting. Very light weight and robust.

I've pushed up some more changes. What do you think now?

Copy link
Member

Choose a reason for hiding this comment

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

LGTM 😄

@eread eread force-pushed the eread/add-support-for-golangci_lint-version-2 branch from 2e0ac76 to e73e398 Compare April 1, 2025 02:47
@kaste kaste merged commit a1be8cf into SublimeLinter:master Apr 1, 2025
1 check passed
@kaste
Copy link
Member

kaste commented Apr 1, 2025

Released as 3.0.0 🚀

@eread
Copy link
Contributor Author

eread commented Apr 1, 2025

Released as 3.0.0 🚀

Thanks @kaste! 🤝

@silverwind
Copy link

silverwind commented Jul 10, 2025

Given that this golangcilint.v1 setting seems to be a global setting, how is one supposed to make it work with a mix of projects where some are on v1 and some on v2?

I suggest to automatically detect version based on version in the configuration file.

@kaste
Copy link
Member

kaste commented Jul 10, 2025

v1 is actually a linter setting, so you can set it in a project file or per syntax or directly on a view. We should have added it to the defaults dict to make that clear. And also to ensure we have a default set at any time.

@silverwind
Copy link

silverwind commented Jul 11, 2025

I won't be polluting my projects with sublime text project files. This version detection should be automatic imho, and the config option should serve as a (non-recommended) override.

@eread
Copy link
Contributor Author

eread commented Jul 13, 2025

I won't be polluting my projects with sublime text project files. This version detection should be automatic imho, and the config option should serve as a (non-recommended) override.

@silverwind That would be an excellent enhancement. You could raise a pull request for that? My pull request was a first simple step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants