Table of Contents
An example linter can be found at here.
The Automatic Way
- Define your building configuration into
.custom-gcl.yml
. - Run the command
golangci-lint custom
(orgolangci-lint custom -v
to have logs). - Define the plugin inside the
linters-settings.custom
section with the typemodule
. - Run your custom version of golangci-lint.
Requirements:
- Go
- git
Configuration Example
.custom-gcl.yml
version: v1.57.0plugins:# a plugin from a Go proxy- module: 'github.com/golangci/plugin1'import: 'github.com/golangci/plugin1/foo'version: v1.0.0# a plugin from local source- module: 'github.com/golangci/plugin2'path: /my/local/path/plugin2
.golangci.yml
linters-settings:custom:foo:type: "module"description: This is an example usage of a plugin linter.settings:message: hellolinters:disable-all: trueenable:- foo
The Manual Way
- Add a blank-import of your module inside
cmd/golangci-lint/plugins.go
. - Run
go mod tidy
(the module containing the plugin will be imported). - Run
make build
. - Define the plugin inside the configuration
linters-settings.custom
section with the typemodule
. - Run your custom version of golangci-lint.
Configuration Example
.golangci.yml
linters-settings:custom:foo:type: "module"description: This is an example usage of a plugin linter.settings:message: hellolinters:disable-all: trueenable:- foo
Reference
The configuration file can be validated with the JSON Schema: https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json
Edit this page on GitHub
# The golangci-lint version used to build the custom binary.# Require.version: v1.56.2# The name of the custom binary.# Optional.# Default: custom-gclname: custom-golangci-lint# The directory path used to store the custom binary.# Optional.# Default: .destination: ./my/path/# The list of the plugins to integrate inside the custom binary.plugins:# a plugin from a Go proxy- module: 'github.com/example/plugin3'version: v1.2.3# a plugin from a Go proxy (with a specific import path)- module: 'github.com/example/plugin4'import: 'github.com/example/plugin4/foo'version: v1.0.0# a plugin from local source (with absolute path)- module: 'github.com/example/plugin2'path: /my/local/path/plugin2# a plugin from local source (with relative path)- module: 'github.com/example/plugin1'path: ./my/local/path/plugin1# a plugin from local source (with absolute path and a specific import path)- module: 'github.com/example/plugin2'import: 'github.com/example/plugin4/foo'path: /my/local/path/plugin2