https://github.com/averagebit/mgg
Scans all project files and generates mocks using mockgen mimicking the project structure.
https://github.com/averagebit/mgg
Last synced: 6 months ago
JSON representation
Scans all project files and generates mocks using mockgen mimicking the project structure.
- Host: GitHub
- URL: https://github.com/averagebit/mgg
- Owner: averagebit
- Created: 2022-05-26T23:25:05.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-06T14:53:18.000Z (almost 4 years ago)
- Last Synced: 2024-06-20T11:56:58.220Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mgg
Scans all files in your project. If the path doesn't contain `_test`,
the prefix flag, ends in `.go` and file contains `interface {` it
generates mocks for that interface using
[mockgen](https://github.com/golang/mock).
## Dependencies
- [mockgen](https://github.com/golang/mock)
## Installation
```
go install github.com/averagebit/mgg@latest
```
## Usage
```
# USAGE:
# mgg [OPTIONS]
#
# OPTIONS:
# -h, --help Prints this help message
# -d, --dir Directory to generate mocks in [default: 'mocks']
# -p, --prefix Prefix to use for mock files [default: 'mock_']
# -i, --ignore Paths to ignore when scanning for interfaces [default: ['']]
```
### Example
```
# .
# |--- .git
# |--- README.md
# |--- go.mod
# |--- main.go # has interface
# |--- mocks
# |--- mock_pkg
# |--- mock_logger.go
# |--- mock_pubsub.go
# |--- pkg
# |--- logger.go # has interface
# |--- pubsub.go # has interface
$ mgg --dir=mocks --prefix=mock_ --ignore=main.go,pkg/logger.go
Generated 'mocks/mock_pkg/mock_pubsub.go'
```
## TODO:
- Respect `.gitignore`.
- Support passing flags to `mockgen`.
- Create unit tests.