franela/goblin

Assertion redeclared during import w/ Gomega

speakingcode opened this issue · 2 comments

package foo

import (
    "testing"
    . "github.com/onsi/gomega"
    . "github.com/franela/goblin"
)

trying to run go test produces the following error:

./foo_test.go:6:5: Assertion redeclared during import "github.com/franela/goblin"
        previous declaration during import "github.com/onsi/gomega"
FAIL    foo/foo [build failed]

go.mod

module foo/foo

go 1.14

require (
	github.com/franela/goblin v0.0.0-20200611003024-99f9a98191cf
	github.com/onsi/gomega v1.10.1
        ...
)

Maybe it's an import alias issue. Does this code solves your problem?

package foo

import (
   "testing"
   "github.com/onsi/gomega"
   . "github.com/franela/goblin"
)

That works but then calls to all of the imported functions from Gomega (Expect, Equal, RegisterFailHandler, etc) must be prepended. What I ended up doing is:

package foo

import (
   "testing"
   . "github.com/onsi/gomega"
   gob "github.com/franela/goblin"
)

func TestFoo(t *testing.T) {
    g := gob.Goblin(t)
   ...

I'll make a PR with the doc fixed.