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 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.
I've stolen the list of "initialisms" from the golint codebase. Normally
I might try and figure out some way to bring the list in from the source
rather than just copy and paste it, since it may fall out of date in the
future. However, if you've ever followed any of the PRs in the golint
repository, you'll know any change like that would likely be rejected.
Most of this list hasn't changed in the last 4 years, so my feeling is
that it won't require many more updates for the life of this project.
when just an empty interface is has beeing mocked, the import of the sync package caused an error. In production it isn't important, because mocking empty interfaces might be stupid, but while writing tests it might happen, that you create an interface, which is beeing filled later on.
The TestDotImports changed the directory, so every test afterwards was executed from another directory and calls like New("testpackages/emptyinterface", "") failed.