-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4daf624
commit 39f6d9f
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
bin/ | ||
vendor/ | ||
|
||
# test coverage | ||
coverage.out | ||
coverage.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# gomockcontrollerfinish | ||
|
||
![CI](https://github.com/hendrywiranto/gomockcontrollerfinish/workflows/CI/badge.svg) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/hendrywiranto/gomockcontrollerfinish)](https://goreportcard.com/report/github.com/hendrywiranto/gomockcontrollerfinish) | ||
[![Coverage Status](https://coveralls.io/repos/github/hendrywiranto/gomockcontrollerfinish/badge.svg?branch=main)](https://coveralls.io/github/hendrywiranto/gomockcontrollerfinish?branch=main) | ||
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) | ||
|
||
A linter that checks whether an unnecessary call to .Finish() on gomock.Controller exists | ||
|
||
## Installation & usage | ||
|
||
``` | ||
$ go install github.com/hendrywiranto/gomockcontrollerfinish@latest | ||
$ gomockcontrollerfinish ./... | ||
``` | ||
|
||
or use `go vet` | ||
``` | ||
$ go build -o gomockcontrollerfinish main.go | ||
$ go vet -vettool=./gomockcontrollerfinish ./... | ||
``` | ||
|
||
## 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) | ||
} | ||
``` |