Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate generates mock code into w that mocks the specified type in a Go source file at the given package name and import path.
If rename is empty, the generated type name will be based on typ.
func GenerateToFileFromFile ¶
func GenerateToFileFromFile( dstFileOrDirPath, dstPkgName, dstTypeName, srcPath, srcPkgName, srcTypeName string, bare bool, ) (dstFilePath string, err error)
GenerateToFileFromFile is a convenience function that combines Resolve, Generate and operations on the file system to write the generated mock code to a file.
func Resolve ¶
func Resolve( dstFileOrDirPath, dstPkgName, dstTypeName, srcPkgName, srcImportPath, srcTypeName string, ) (filePath, pkgName, importPath, typeName string, err error)
Resolve resolves the destination file path, package name and import path.
If dstPkgName is empty, pkgName will be the name of the destination directory, or srcPkgName if the destination directory is the current directory.
The destination directory is resolved from dstFileOrDirPath. If empty, the current directory is used. If a path to what looks like a Go source file, its base directory is used. Otherwise, it is taken to be the explicit path to the destination directory.
If dstFileOrDirPath didn't specify a destination Go source file, filePath is resolved from typeName by prefixing with 'mock_' and suffixing with '_test.go'.
If dstTypeName is left empty, srcTypeName is used.
The import path is resolved from the destination directory and srcImportPath. The destination directory must be resolved to a path that is under srcImportPath.