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

Duplicate import statements with gowrap >=1.4.0 #98

Open
ghouscht opened this issue Dec 31, 2024 · 0 comments
Open

Duplicate import statements with gowrap >=1.4.0 #98

ghouscht opened this issue Dec 31, 2024 · 0 comments

Comments

@ghouscht
Copy link

ghouscht commented Dec 31, 2024

Hi,
First of all thank you for your work on gowrap, I really like it and use it in various projects.

However, since version 1.4.0 I have some issues in more complex projects that seem to be caused by #92. I'm using the gowrap {{.Import}} template and in my case that generates the following imports if the gowrap version is >=1.4.0:

import (
	"time"

	"github.com/prometheus/client_golang/prometheus"
	_sourceUser "<redacted>/internal/user/service/user"
	"<redacted>/internal/user/service/user/models"

	_sourceUser "<redacted>/internal/user/service/user"
)

As you can see the user import is duplicated.

With version 1.3.10 and same arguments to gowrap the imports are generated as follows:

import (
	"time"

	"github.com/prometheus/client_golang/prometheus"
	"<redacted>/internal/user/service/user"
	"<redacted>/internal/user/service/user/models"
)

Any idea how this can be fixed? I'm trying to create a simple reproducer for this but so far I wasn't successful.

Here is a simple reproducer: https://github.com/ghouscht/gowrap-issue-98

In my case I'm not using import aliases in the package where the interface and go generate statement sits but the outcome is the same = duplicate imports.

ghouscht added a commit to ghouscht/gowrap-issue-98 that referenced this issue Dec 31, 2024
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

1 participant