Add fmt flag to specify formatter (#117)
- Support formatting output with gofmt(default) or goimports via flag. - Introduce moq.Config struct to configure moq.Mocker instance. This breaks backward compatibility but facilitates it in the future if and when any features are added. - Use golden file tests for validating formatters. Use github.com/pmezard/go-difflib to print the diff between expected and actual.
This commit is contained in:
@@ -24,7 +24,9 @@ $ go get github.com/matryer/moq
|
||||
### Usage
|
||||
|
||||
```
|
||||
moq [flags] destination interface [interface2 [interface3 [...]]]
|
||||
moq [flags] source-dir interface [interface2 [interface3 [...]]]
|
||||
-fmt string
|
||||
go pretty-printer: gofmt (default) or goimports
|
||||
-out string
|
||||
output file (default stdout)
|
||||
-pkg string
|
||||
@@ -33,6 +35,9 @@ Specifying an alias for the mock is also supported with the format 'interface:al
|
||||
Ex: moq -pkg different . MyInterface:MyMock
|
||||
```
|
||||
|
||||
**NOTE:** `source-dir` is the directory where the source code (definition) of the target interface is located.
|
||||
It needs to be a path to a directory and not the import statement for a Go package.
|
||||
|
||||
In a command line:
|
||||
|
||||
```
|
||||
|
Reference in New Issue
Block a user