Closed msoap closed 5 years ago
Just hit that, too.
@msoap as a workaround you can use a named import like this:
import uberatomic "go.uber.org/atomic"
@msoap glad to see you again and thank you for raising the issue. @deadok22 thanks for the workaround
I'll fix it soon.
@msoap @deadok22 please check if the latest 2.1.3 version works for you
Thanks for jumping onto this @hexdigest. Unfortunately, the fix doesn't work for me.
Here's how to reproduce the issue:
$ env | grep GO
GO111MODULE=on
GOROOT=/usr/local/go
go generate
:
/tmp$ tar fx i27.tar.gz
/tmp$ cd i27/
/tmp/i27$ go generate ./...
minimock: ./jwttest/token_issuer_mock.go
/tmp/i27$ cat ./jwt/jwttest/token_issuer_mock.go | grep v3
"github.com/gbrlsnchs/jwt/v3"
github.com/gbrlsnchs/jwt/v3
should not be importedWhile reproducing the issue I've noticed another issue: -o
option is broken for empty directories - filed #28
@deadok22
These are different issues actually. In your case both packages "github.com/gbrlsnchs/jwt/v3" and "example.com/example/i27/jwt" have same identifier which is "jwt". What minimock does is it includes all imports from the original file into the destination file and hope that goimports will fix imports which is not happening here because packages have same id and there there are references to "jwt" id in the generated code.
I'll think what I can do here. As a workaround you can try using an alias for "github.com/gbrlsnchs/jwt/v3"
in the source file, i.e. jwtoken "github.com/gbrlsnchs/jwt/v3"
I must have misunderstood the original ticket then. I thought it was about having import "go.uber.org/atomic"
in a package named atomic
, but now I see it's about the mock-related "sync/atomic" usages. Thanks for clarifying this!
The workaround I suggested earlier works in this case, too - that's exactly what I was doing when I first saw this ticket.
As for the proper fix, I guess implementing some logic for generating aliases would be the only way to go...
@deadok22 please check if version 2.1.4 works for you #28 should be fixed in this release either.
Thanks @hexdigest! 2.1.4
works fine for me, albeit it's a bit to aggressive in introducing aliases: in the example I shared above there is only one "jwt" import in the mock destination package, so aliasing is not required. Improving this in the future might be a good idea.
@hexdigest thank you, now it works fine.
Hi, great tool:), but is not working with interfaces with
.../atomic
types like"go.uber.org/atomic"
.For example for interface:
minimock generates mock:
which produce build error: