Skip to content

Duplicate import statements with gowrap >=1.4.0 #98

Open
@ghouscht

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions