以下是我的文件夹 struct :
demo/
|-- go.mod
|-- main.go
|-- interfaces/
| |-- interfaces.go
|-- mocks/
这是我的go.mod文件
go 1.20
require (
github.com/golang/mock v1.6.0 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/tools v0.1.1 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
这是我的界面.开始
package interfaces
type MyInterface interface {
DoSomething() error
GetValue() int
}
当我try 运行mockgen命令时,它并没有创建模拟,而是给了我这个帮助描述: mockgen有两种操作模式:source和reflect.Source模式从源文件生成mock接口.它通过使用-source标志启用.在此模式下可能有用的其他标志是-imports和-aux_files.
我运行了以下命令:mockgen -destination=mocks/mock_myinterface.go -package=mocks demo/interfaces MyInterface
如何正确使用moockgen命令?