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

Add support for internal packages #74

Open
geekofalltrades opened this issue Jun 20, 2023 · 2 comments
Open

Add support for internal packages #74

geekofalltrades opened this issue Jun 20, 2023 · 2 comments

Comments

@geekofalltrades
Copy link

When I try to generate a wrapper from an interface in an internal package, gowrap fails.

/path/to/package/internal/generated/prom_test.go:

package generated

//go:generate gowrap gen -g -p . -i TestInterface -t prometheus -o prom.go

type TestInterface interface{
    TestMethod()
}
go generate ./...
failed to parse source package: open repo.git/path/to/package/internal/generated: no such file or directory
internal/generated/prom_test.go:3: running "gowrap": exit status 1

Moving the file out of the internal subpackage makes it work.

@hexdigest
Copy link
Owner

Hey @geekofalltrades,

I think the problem here is a _test.go suffix rather than internal package because it works fine with internal packages.
Try putting the interface you're trying to generate decorator for somewhere else. There's not very much sense to parse test files.

Let me know if it's your case. I think I have to document it because it's not the first time people face this issue.

@geekofalltrades
Copy link
Author

geekofalltrades commented Jun 27, 2023

This seemed to be working in a _test.go file when I moved that file out of an internal package.

Also, it makes sense to me to have this particular interface in a _test.go file, because I'm using it to test a custom gowrap template.

But, there was no non-_test.go-suffixed file in the directory, so possibly the whole directory was not registering as a Go package. And when I moved it out of the internal package, it was into a directory that had other go files in it that were not _test.go files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants