Skip to content

Duplicate imports with different names in multiple files cause error #9

@nkovacs

Description

@nkovacs

Assuming you have these two files:

package foo

import (
    pkg1 "github.com/user/pkg"
)

type FooStruct{}

func (f *FooStruct) One(pkg1.Foo) {
}
package foo

import (
    pkg2 "github.com/user/pkg"
)

func (f *FooStruct) Two(pkg2.Foo) {
}

If you pass both files to ifacemaker, it will generate:

import (
    pkg1 "github.com/user/pkg"
    pkg2 "github.com/user/pkg"
)

type FooInterface {
    One(pkg1.Foo)
    Two(pkg2.Foo)
}

which is not valid because of the duplicate imports.

Similarly problematic are pkg1 "github.com/user/pkg" + "github.com/user/pkg" and even pkg "github.com/user/pkg" + "github.com/user/pkg".

I'm not sure if it's worth fixing this. The hardest part is probably finding an alias that doesn't conflict, after that, aliasing everything should be easier.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions