gomocklinter

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 2 Imported by: 0

README

gomocklinter

CI Go Report Card Coverage Status MIT License

A linter that checks the usage of go mocking libraries

Note: The original golang/mock package is archived and the maintained fork is go.uber.org/mock.
This linter supports both.

Installation & usage

$ go install github.com/hendrywiranto/gomocklinter@latest
$ gomocklinter ./...

or build the binary and use go vet

$ go build -o gomocklinter main.go
$ go vet -vettool=./gomocklinter ./...

Motivation

As highlighted in https://pkg.go.dev/github.com/golang/mock/gomock#NewController

New in go1.14+, if you are passing a *testing.T into this function you no longer need to call ctrl.Finish() in your test methods.

Examples

// Bad
func TestFoo(t *testing.T) {
	mock := gomock.NewController(t)
	defer mock.Finish() // no need to call this since go1.14
}

// Good
func TestFoo(t *testing.T) {
	mock := gomock.NewController(t)	
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL