Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 1.3 KB

README.md

File metadata and controls

72 lines (50 loc) · 1.3 KB

mockguard

mockguard checks if mockgen is used in conventional filename and options.

Config

mockguard provides default convention. Please see config.go

You can overwrite via commandline option or golangci setting.

  • FileName
  • Content

Install

$ go install github.com/cloverrose/mockguard/cmd/mockguard@latest

Or Build from source

$ go build -o bin/ ./cmd/...

Or Install via aqua

https://aquaproj.github.io/

Usage

$ go vet -vettool=`which mockguard` ./...

When you specify config

go vet -vettool=`which mockguard` \
  -mockguard.FileName=types.go \
  -mockguard.Content='//go:generate mockgen -source=$GOFILE -package=$GOPACKAGE --destination=mock_$GOFILE' \
   ./...

Or golangci-lint custom plugin

https://golangci-lint.run/plugins/module-plugins/

Here are reference settings

.custom-gcl.yml

version: v1.62.0
plugins:
  - module: 'github.com/cloverrose/mockguard'
    import: 'github.com/cloverrose/mockguard'
    version: v0.1.0

.golangci.yml

linters-settings:
  custom:
    mockguard:
      type: "module"
      description: check mockgen usage.
      settings:
        FileName: types.go
        Content: "//go:generate mockgen -source=$GOFILE -package=$GOPACKAGE --destination=mock_$GOFILE"