Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion redeclared during import w/ Gomega #88

Closed
speakingcode opened this issue Jul 21, 2020 · 2 comments · Fixed by #93
Closed

Assertion redeclared during import w/ Gomega #88

speakingcode opened this issue Jul 21, 2020 · 2 comments · Fixed by #93

Comments

@speakingcode
Copy link
Contributor

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
        ...
)
@Neirpyc
Copy link
Contributor

Neirpyc commented Aug 24, 2020

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"
)

@speakingcode
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants