* fix: bump xtools to 0.1.9 to support go 1.18
* bump x/tools version to 0.1.10
* add go version 1.17 and 1.18 to the CI build matrix
* exclude 1.14 from macos and windows builds.
This change adds windows and macos to the matrix and excludes 1.14 from running on windows or macos. This matches the original behaviour of the CI build inverting the includes/excludes options
File is removed before mock generation, if it exists. This is useful
when the mock generation is likely to fail due to some reason, for
example, package load failure due to change in the interface being
mocked (the existing mock is no longer valid and cannot be compiled). In
such cases, the -rm flag can be used instead of manually removing the
file (which could have fixed the issue).
When the type and the package name is the same for an anonymous
parameter (ex: time.Time), and there are more than 1 such parameters,
the generated name for both was the same. And the generated code would
not be valid.
Fix the bug by ensuring the parameter name does not conflict with
package imports first before checking against other parameter names.
* Internal registry for disambiguated imports, vars
- Move functionality in the moq package partially into
internal/{registry,template}.
- Leverage registry to assign unique package and variable/method
parameter names. Use import aliases if present in interface source
package.
BREAKING CHANGE: When the interface definition does not mention the
parameter names, the field names in call info anonymous struct will be
different.
The new field names are generated using the type info (string -> s,
int -> n, chan int -> intCh, []MyType -> myTypes, map[string]int ->
stringToInt etc.).
For example, for a string parameter previously if the field name was
'In1', the new field could be 'S' or 'S1' (depends on number of
string method parameters).
* Refactor golden file tests to be table-driven
* Fix sync pkg alias handling for moq generation
* Improve, add tests (increase coverage)
* Use $.Foo in template, avoid declaring variables
$ is set to the data argument passed to Execute, that is, to the
starting value of dot.
Variables were declared to be able to refer to the parent context.
* Consistent template field formatting
* Use tabs in generated Godoc comments' example code
* Minor simplification
* go generate
* Fix conflict for generated param name of pointer type
Excellent work by @sudo-suhas.
For mocks generated outside of the tested package with tests lives inside the same package as the tested code (i.e. pkg_test not used) --skip-ensure suppresses import of the source pkg
https://github.com/matryer/moq/issues/139
fix typo in readme