Not able to install dockertest

Hey, I run into a problem when trying to use dockertest.First, I run go get -u [github.com/ory/dockertest/v3](http://github.com/ory/dockertest/v3) and got

package github.com/ory/dockertest/v3: cannot find package "github.com/ory/dockertest/v3" in any of:
	/usr/local/go/src/github.com/ory/dockertest/v3 (from $GOROOT)
	/Users/evan/source/golib/src/github.com/ory/dockertest/v3 (from $GOPATH)
	/Users/evan/source/go/src/github.com/ory/dockertest/v3

I check my $GOPATH/src/github.com/ory/dockertest and it exists, but I don’t find anything specific to v3. Then I add a test like

package test
import (
	"log"
	"net/http"
	"net/http/httptest"
	"testing"
	_ "github.com/lib/pq"
	"github.com/ory/dockertest/v3"
	"github.com/yiksanchan/tijianqueue/backend/api"
)
func TestDockerIt(t *testing.T) {
	pool, err := dockertest.NewPool("")
	if err != nil {
		log.Fatalf("Could not connect to docker: %s", err)
	}
	resource, err := pool.Run("postgres", "11.5", []string{"POSTGRES_PASSWORD=password"})
	if err != nil {
		log.Fatalf("Could not start resource: %s", err)
	}
}

then cd test , go test -v , this is what I got:

# github.com/yiksanchan/tijianqueue/backend/test
package github.com/yiksanchan/tijianqueue/backend/test (test)
	imports github.com/ory/dockertest/v3: cannot find package "github.com/ory/dockertest/v3" in any of:
	/usr/local/go/src/github.com/ory/dockertest/v3 (from $GOROOT)
	/Users/evan/source/golib/src/github.com/ory/dockertest/v3 (from $GOPATH)
	/Users/evan/source/go/src/github.com/ory/dockertest/v3
FAIL	github.com/yiksanchan/tijianqueue/backend/test [setup failed]

then I change import

"github.com/ory/dockertest/v3"

into

"github.com/ory/dockertest"

in imports, and I got this:

# github.com/yiksanchan/tijianqueue/backend/test
package github.com/yiksanchan/tijianqueue/backend/test (test)
	imports github.com/ory/dockertest
	imports github.com/ory/dockertest/v3/docker
	imports github.com/ory/dockertest/v3/docker/pkg/jsonmessage
	imports github.com/Nvveen/Gotty: cannot find package "github.com/Nvveen/Gotty" in any of:
	/usr/local/go/src/github.com/Nvveen/Gotty (from $GOROOT)
	/Users/evan/source/golib/src/github.com/Nvveen/Gotty (from $GOPATH)
	/Users/evan/source/go/src/github.com/Nvveen/Gotty
FAIL	github.com/yiksanchan/tijianqueue/backend/test [setup failed]

any help? thx

You need to use Go Modules and a Go version that supports Go Modules

1 Like