Skip to content

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

Notifications You must be signed in to change notification settings

cloverrose/mockguard

Repository files navigation

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"

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages