rpcguard
is collection of connect-RPC usage linters which check if connect-RPC method is implemented properly.
- rpc_callvalidate: check if RPC method uses Validate method properly
- rpc_wraperr: check if RPC method returns wrapped error
rpc_callvalidate
provides options. Please see callvalidate/config.gorpc_wraperr
provides options. Please see wraperr/config.go
You can overwrite via commandline option or golangci setting.
$ go install github.com/cloverrose/rpcguard/cmd/callvalidate@latest
$ go install github.com/cloverrose/rpcguard/cmd/wraperr@latest
$ make build
$ go vet -vettool=`which rpc_callvalidate` ./...
$ go vet -vettool=`which rpc_wraperr` -rpc_wraperr.IncludePackages="$(go list -m)/.*" ./...
Note: rpc_wraperr.IncludePackages is required option.
When you specify config
go vet -vettool=`which rpc_callvalidate` \
-rpc_callvalidate.log.level=ERROR \
./...
go vet -vettool=`which rpc_wraperr` \
-rpc_wraperr.IncludePackages="$(go list -m)/.*" \
-rpc_wraperr.log.level=ERROR \
-rpc_wraperr.ReportMode=RETURN \
./...
https://golangci-lint.run/plugins/module-plugins/
Here are reference settings
.custom-gcl.yml
version: v2.3.1
plugins:
- module: 'github.com/cloverrose/rpcguard'
import: 'github.com/cloverrose/rpcguard'
version: v0.6.3
.golangci.yml
linters-settings:
custom:
rpc_callvalidate:
type: "module"
description: check if RPC method uses Validate method properly.
settings:
log:
level: "ERROR"
file: "./log.txt"
rpc_wraperr:
type: "module"
description: check if RPC method returns wrapped error.
settings:
log:
level: "ERROR"
file: "./log.txt"
ReportMode: "RETURN"
IncludePackages: "github.com/cloverrose/linterplayground/.*"