- 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.
- Use travis build matrix to test on Windows and macOS
- Make utility func compatible with host OS. Use filepath package to
manipulate path strings for stripping $GOPATH from working directory.
- Delegate to go/build pkg for getting Go paths
Co-authored-by: Mike Lee <mike.lee@safeguardproperties.com>
Co-authored-by: Lucas Bremgartner <lucas@bremis.ch>
When the interface that we are trying to moq is present inside the vendor
directory and the output package name is different, the import needs to be
stripped of the vendor path.
From the docs for packages.{LoadFiles, LoadSyntax} -
https://godoc.org/golang.org/x/tools/go/packages#pkg-constants
// Deprecated: LoadFiles exists for historical compatibility
// and should not be used. Please directly specify the needed
// fields using the Need values.
// ...
// Deprecated: LoadSyntax exists for historical compatibility
// and should not be used. Please directly specify the needed
// fields using the Need values.
If a PR is created using a branch pushed to origin, this triggers travis
CI twice, once for the PR and another for the branch. So run travis CI for
only the master branch and when PRs are created using origin branches.
If CI needs to be run on any specific branch other than master, it would
need to be whitelisted.
Co-authored-by: Mat Ryer <matryer@users.noreply.github.com>
If the user specifies a different package and the mock name is the same
as the interface name, the type guard comment will be of the following
format:
// Ensure, that MyInterface does implement MyInterface.
So use the $sourcePackagePrefix in the comment.
Add an additional line of code per interface to the generated mock file,
which allows the go compiler to statically check if the mock implements
the mocked interface.