Skip to content

Duplicate import statements with gowrap >=1.4.0 #98

@ghouscht

Description

@ghouscht

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.

Metadata

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