gojuno / minimock

Powerful mock generation tool for Go programming language
MIT License
577 stars 38 forks source link

missing imports #24

Closed NOMORECOFFEE closed 5 years ago

NOMORECOFFEE commented 5 years ago

internal/pkg/app/app.go

package app

import (
    desc "<github path to>/internal/pkg/protobuf"
)

type App interface {
    Run(*desc.Args) error
}

/internal/pkg/protobuf

package protobuf

type Args struct {
    Y int
}

internal/app/mock/doc.go

package mock

Run minimock version 2.1.0 minimock -i "./internal/pkg/app.*" -o "./internal/app/mock/" -s "_mock.go" and got

package mock

// DO NOT EDIT!
// The code below was generated with http://github.com/gojuno/minimock (2.1.0)

//go:generate minimock -i <github path to>/internal/pkg/app.App -o ./internal/app/mock/app_mock.go

import (
    "sync/atomic"
    "time"

    "github.com/gojuno/minimock"
)

// AppMock implements app.App
type AppMock struct {
    t minimock.Tester

    funcRun          func(ap1 *desc.Args) (err error)
    afterRunCounter  uint64
    beforeRunCounter uint64
    RunMock          mAppMockRun
}
....

missing import is desc "<github path to>/internal/pkg/protobuf"

NOMORECOFFEE commented 5 years ago

doesn't work to internal/pkg/app/app.go

package app

import (
    desc "<github path to>/internal/pkg/protobuf"
)

type Args desc.Args

type App interface {
    Run(*Args) error
}

missing import is "<github path to>/internal/pkg/app"

hexdigest commented 5 years ago

Hi, @NOMORECOFFEE !

Thanks for raising the issue. Minimock uses goimports package to fix the imports. I checked that goimports doesn't work either. I tried to use goimports program against the generated file and no imports were inserted by goimports.

However, there's a way to fix it, stay tuned!