uber-go / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
2.33k stars 121 forks source link

Relative path as parameter values for -source and -destination #174

Closed Abhishekkarunakaran closed 1 month ago

Abhishekkarunakaran commented 7 months ago

Currently we have to pass the whole path of the files as values to the flags -source and -destination. eg: mockgen -source=D:\go_project\library_management\src\core\ports\repository.go -destination=D:\go_project\library_management\src\core\mocks\respository_mock.go (In windows)

To reduce this redundancy in type, we can use the relative path. Assuming mockgen is used from the targeted codebase.

Abhishekkarunakaran commented 7 months ago

Is there any particular reason to make it as what it is now?

r-hang commented 7 months ago

Hey @Abhishekkarunakaran, I see examples of relative paths being passed to the --source and --destination options for the mockgen command in the //go:generate comments of multiple files in the repository.

Abhishekkarunakaran commented 7 months ago

In my understanding, the relative path is only available in reflect mode, not in source mode.

lgarcia93 commented 1 month ago

In Windows, to avoid passing the full path like -source=D:\go_project\library_management\src\core\ports\repository.go you can pass the relative path between quotes like this -source="src/core/ports/repository.go".