Skip to content

Commit

Permalink
Improve readme (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrywiranto committed Nov 12, 2023
1 parent 4daf624 commit 39f6d9f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
bin/
vendor/

# test coverage
coverage.out
coverage.html
38 changes: 38 additions & 0 deletions README.md
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)
}
```

0 comments on commit 39f6d9f

Please sign in to comment.