Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/utgwkk/bulkmockgen
Generate mock code all at once
https://github.com/utgwkk/bulkmockgen
golang mock
Last synced: about 2 months ago
JSON representation
Generate mock code all at once
- Host: GitHub
- URL: https://github.com/utgwkk/bulkmockgen
- Owner: utgwkk
- License: mit
- Created: 2023-07-08T03:18:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T14:30:39.000Z (about 2 months ago)
- Last Synced: 2024-10-29T15:57:08.062Z (about 2 months ago)
- Topics: golang, mock
- Language: Go
- Homepage:
- Size: 112 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# bulkmockgen
Generate mock code all at once
## Installation
```
go install github.com/utgwkk/bulkmockgen/cmd/bulkmockgen@latest
```## Usage
```go
// foo/foo.go
package fooimport "context"
type IFoo interface {
Do(ctx context.Context) error
}type IBar interface {
Do(ctx context.Context) error
}var Iset = []any{
new(IFoo),
new(IBar),
}
``````
$ bulkmockgen -use_go_run Iset -- -package mock_foo -destination ./mock_foo/mock.go
```You can use bulkmockgen with `go:generate` comment.
```go
package foo//go:generate bulkmockgen -use_go_run Iset -- -package mock_foo -destination ./mock_foo/mock.go
var Iset = []any{
new(IFoo),
new(IBar),
}
```## Restriction
- Bulkmockgen is available for gomock's package mode. Source mode is currently not available.
## Migrate from mockgen
There is a migration tool `mockgen-to-bulkmockgen`. You can rewrite `//go:generate mockgen` comments to bulkmockgen's all at once.
```
go install github.com/utgwkk/bulkmockgen/cmd/mockgen-to-bulkmockgen@latest
```Note that this migration tool can't migrate external interface mocking.