Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag -write_generate_directive produces wrong paths in the directive #135

Open
maratori opened this issue Dec 31, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@maratori
Copy link

Actual behavior

Flag -write_generate_directive adds the go:generate directive, ignoring the future working directory. That leads to a failure of go generate.

Expected behavior

go:generate directive should be changed to respect that the current working directory will be different from the original execution.

To Reproduce

echo 'package pkg' > file.go
mockgen -write_generate_directive -source file.go -destination mocks/mock.go
grep 'go:generate' mocks/*
//go:generate mockgen -write_generate_directive -source file.go -destination mocks/mock.go
go generate ./...
2023/12/31 15:40:41 Loading input failed: failed parsing source file file.go: open file.go: no such file or directory
mocks/mock.go:12: running "mockgen": exit status 1

To fix

sed -i '' -e 's#-source file.go -destination mocks/mock.go#-source ../file.go -destination mock.go#' mocks/*
grep 'go:generate' mocks/*
//go:generate mockgen -write_generate_directive -source ../file.go -destination mock.go
go generate ./...
@r-hang r-hang added the bug Something isn't working label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants