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

Custom plugins path should be relative to the configuration file #1085

Closed
aymericbeaumet opened this issue May 13, 2020 · 2 comments · Fixed by #1572
Closed

Custom plugins path should be relative to the configuration file #1085

aymericbeaumet opened this issue May 13, 2020 · 2 comments · Fixed by #1572
Labels
enhancement New feature or improvement

Comments

@aymericbeaumet
Copy link

aymericbeaumet commented May 13, 2020

When I run golangci-lint from a directory which is not where the configuration file (e.g.: .golangci.yml) exists, then the custom plugin path is resolved relative to the current working directory, and not to where the configuration file resides.

In my case the issue I'm facing is that the vim linter Ale doesn't know what is the root directory of the go module I'm working on, and runs the linter from the package directory with something like: cd $(dirname $file) && golangci-lint run .

I would like the relative paths from .golangci.yml to be relative to the file itself, so that the resolving behaviour would be agnostic to the cwd.

In the example below, the plugin will (with latest master) be resolved as $(pwd)/.go/bin/foobar.so. I think it should instead be resolved as ~/some-project/.go/.bin/foobar.so, making this deterministic regardless of the current working directory:

# ~/some-project/.golangci.yml
linters-settings:
  custom:
    foobar:
      path: .go/bin/foobar.so

It's also possible to address this issue without breaking the current behavior by taking inspiration from Jest's <rootDir> which is being expanded when the configuration file is loaded. So we could do something like:

linters-settings:
  custom:
    foobar:
      path: <rootDir>/.go/bin/foobar.so
@oschwald
Copy link

I also ran this while trying to enable ruleguard rules (via gocritic for our project). I haven't found a great workaround.

@aymericbeaumet
Copy link
Author

What we have ended up doing is leverage a target in our Makefile to dynamically generate the Golint configuration file so that the .so can be an absolute path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
2 participants