Plugin for golangci-lint
Interfaceguard plugin for golangci-lint
Example Config
.golangci.yml
linters-settings:
custom:
interfaceguard:
type: module
description: interfaceguard checks subtle interface-related issues, including improper comparisons and type mismatches.
original-url: https://github.com/jkeys089/interfaceguard
settings:
# Disable check for direct interface-to-interface comparisons.
# Default: false
disable-interface-to-interface: true
# Disable check for direct interface-to-nil comparisons.
# Default: false
disable-interface-to-nil: true
linters:
disable-all: true
enable:
- interfaceguard
How To Run
Preferred Method - utilize golangci-lint custom
command:
- create a
.custom-gcl.yml
config like below (see reference for all options):
version: v1.60.3
plugins:
- module: 'github.com/jkeys089/interfaceguard/plugin/golangci'
import: 'github.com/jkeys089/interfaceguard/plugin/golangci/module'
version: latest
- build and run custom-gcl
golangci-lint custom
./custom-gcl linters | grep interfaceguard
./custom-gcl run ./...
Alternative Method - utilize the go plugin package (requires golangci-lint be built with CGO_ENABLED
and only supported on Linux, FreeBSD, and macOS):
- build the plugin for your system:
git clone https://github.com/jkeys089/interfaceguard
cd interfaceguard/plugin/golangci
go build -o interfaceguard.so -buildmode=plugin plugin.go
- update
linters-settings.custom.interfaceguard
in .golangci.yml
to use path
param instead of type: module
:
linters-settings:
custom:
interfaceguard:
path: /path/to/interfaceguard.so
description: interfaceguard checks subtle interface-related issues, including improper comparisons and type mismatches.
original-url: https://github.com/jkeys089/interfaceguard
settings:
# Disable check for direct interface-to-interface comparisons.
# Default: false
disable-interface-to-interface: true
# Disable check for direct interface-to-nil comparisons.
# Default: false
disable-interface-to-nil: true
linters:
disable-all: true
enable:
- interfaceguard
- run golangci-lint as normal
golangci-lint linters | grep interfaceguard
golangci-lint run ./...