skip to content
Alvin Lucillo

Generate mock in specified file

/ 1 min read

By default, the generated file takes the name of the service and the exact case, so in the example below, it would have the generated file name: Service.go. To override that, use --filename=api_service.go.

//go:generate mockery --name=Service --dir=. --output=../../mocks/services --outpkg=servicemock --filename=api_service.go

type Service interface {
	GetRows(ctx context.Context) ([]any, error)
}