Skip to content

support automatically building plugin linters #2566

Open
@ashanbrown

Description

@ashanbrown

Your feature request related to a problem? Please describe.

Currently you have to build a plugin locally at a known path prior to running golangci-lint, which creates a challenge for setting up dev and CI environments that use this plugin.

Describe the solution you'd like.

I think one way to address this would be to add a new field, perhaps called "build" to the custom configuration. For example, it might look like this:

  custom:
    gofmts:
      build: github.com/ashanbrown/gofmts/golangci-lint
      description: gofmts sort formatter
      original-url: github.com/ashanbrown/gofmts

What I think this would do is run:

go build -o <some path in the cache>/plugin.so  --buildmode=plugin github.com/ashanbrown/gofmts/golangci-lint

and then auto-determine the path field based on where the plugin is built.

This appears to work within a module-based environment that also includes golangci-lint in the go.mod file.

The one question I have is where the plugins would be stored. We use a cache directory that is shared between versions of golang ci lint (on my mac its ~/Library/Caches/golangci-lint/) and the plugin.so files need to be built for a precise set of dependencies, so the path to the plugin file should probably be some hash including all of the dependencies. Despite the shared cache, it might make sense just to have a plugin per package/plugin pair and ignore the dependencies in the path, so that we don't leak old plugins.

Describe alternatives you've considered.

I think think the alternative is to instrument dev and CI environments to build the plugin themselves.

Additional context.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvementlinter: customAbout custom/private linters

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions